Webfrom Small Program "Paging function"

Source: Internet
Author: User

Method

        }        /*Table Style*/. tab {width: -%; Background-Color:blue; Text-Align:center; }    </style>"Form1"runat="Server"> <divclass="Div1"> Singularity 0216 class Student information </div> <div> <a href="zhuce.aspx"target="_blank"> Add new Classmates </a> </div> <%--add data using Repeater--%> <asp:repeater id="Repeater1"runat="Server"> <HeaderTemplate> <%--head template--%> <tableclass="Tab"> <tr style="color:white; height:30px;"> <td> numbering </td> <td> user name </td>                        <td> password </td> <td> nickname </td> <td> sex </td> <td> Birthdays </td> <td> ages </td> &LT;TD&G t; nationalities </td> <td> settings </td> </tr> "Background-color:white;"> <td><% #Eval ("Ids")%></td> <td><% #Eval ("Username")%></td> <td><% #Eval ("Password")%></td> <td><% #Eval ("Nickname")%></td> <td><% #Eval ("Sexstr")%></td> <td><% #Eval ("Birthdaystr")%></td> <td><% #Eval (" Age")%></td> <td><% #Eval ("Nationname")%></td> <td> <a href="xiugai.aspx?i=<% #Eval ("Ids")%>"> Edit </a> <a onclick="return confirm (' Do you want to delete the <% #Eval ("Nickname")%>? ');"href="shanchu.aspx?i=<% #Eval ("Ids")%>"> Delete </a> </td> </tr> </ItemTemplate> &lt ;        footertemplate> <%--foot template--%> </table> </FooterTemplate> </asp:Repeater> <br/><br/><br/>current Section [<asp:label id="LAB1"runat="Server"text="1"></asp:Label>] Page Total [<asp:label id="LAB2"runat="Server"text="1"></asp:Label>] Page<asp:button id="But_first"runat="Server"text="Home Page"/> <asp:button id="but_up"runat="Server"text="Previous Page"/> <asp:button id="But_down"runat="Server"text="Next Page"/> <asp:button id="But_last"runat="Server"text="last page"/> <asp:dropdownlist id="DR1"runat="Server"></asp:DropDownList> <asp:button id="But_jump"runat="Server"text="Jump"/> </form></body>Front desk

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls; Public Partial class_default:system.web.ui.page{intPageCount =Ten;//show number of bars per page    protected voidPage_Load (Objectsender, EventArgs e) {        if(!IsPostBack) {            //code executed only the first time it is loaded//Data display is not required, data display to show the latest dataRepeater1.datasource =NewUsersdata (). Selecttop (PageCount,1);            Repeater1.databind (); Lab2.text= Pageall (). ToString ();//Total Pages             for(inti =1; I <= Pageall (); i++) {ListItem Li=NewListItem (); Li. Text=i.tostring (); Li. Value=i.tostring ();                        Dr1.Items.Add (LI); }} but_first. Click+=But_first_click; But_last. Click+=But_last_click; But_up. Click+=But_up_click; But_down. Click+=But_down_click; But_jump. Click+=But_jump_click; }    //Jump    voidBut_jump_click (Objectsender, EventArgs e) {        intLab =Convert.        ToInt32 (Dr1.selectedvalue); Repeater1.datasource=Newusersdata (). Selecttop (PageCount, Lab);        Repeater1.databind (); Lab1.text=Lab.    ToString (); }    //Next Page    voidBut_down_click (Objectsender, EventArgs e) {        //get current page, calculate next page        intLab = Convert.ToInt32 (lab1.text) +1; if(Lab >Pageall ()) {            return; }        //binding a page of dataRepeater1.datasource =Newusersdata (). Selecttop (PageCount, Lab);        Repeater1.databind (); //Modify the number of pages currently displayedLab1.text =Lab.    ToString (); }    //Previous Page    voidBut_up_click (Objectsender, EventArgs e) {        //Gets the current page, calculates the previous page        intLab = Convert.ToInt32 (Lab1.text)-1; if(Lab <1)        {            return; }        //binding a page of dataRepeater1.datasource =Newusersdata (). Selecttop (PageCount, Lab);        Repeater1.databind (); //Modify the number of pages currently displayedLab1.text =Lab.    ToString (); }    //last page    voidBut_last_click (Objectsender, EventArgs e) {Repeater1.datasource=Newusersdata (). Selecttop (PageCount, Pageall ());        Repeater1.databind (); Lab1.text=Pageall ().    ToString (); }    //Home Page    voidBut_first_click (Objectsender, EventArgs e) {Repeater1.datasource=NewUsersdata (). Selecttop (PageCount,1);        Repeater1.databind (); Lab1.text="1"; }    //Calculate how many pages you have     Public intPageall () {intA =0; intall =NewUsersdata ().        SelectCount (); decimalD = convert.todecimal (all)/PageCount;//int divided by int will automatically remove the decimal point.a= Convert.ToInt32 (math.ceiling (d));//take the upper limit        returnA; }}
Backstage

Autopostback= "true"--auto-commit

dropdownlist1.selectedindexchanged--------the corresponding delegate event

Webfrom Small Program "Paging function"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.