asp.net how to implement Access database paging-practical tips

Source: Internet
Author: User

asp.net operation Access database is a common application of database operations, this article is an example to explain how to implement Access database asp.net. I hope that the ASP.net program design can help.

The specific example code is as follows:

<divclass= "page" id= "Ctrlrecordpage" > Total <asp:labelid= "zpage" runat= "Server" text= "1" ></asp:Label> Page/<asp:labelid= "Zcount" runat= "server" text= "0" ></asp:Label> bar <asp:linkbuttonid= "Start_button" runat= "Server" onclick= "Start_button_click" > Home </asp:LinkButton> <asp:linkbuttonid= "Up_button" runat= " Server "onclick=" Up_button_click > Prev </asp:LinkButton> <asp:linkbuttonid= "Down_button" runat= "Server" onclick= "Down_button_click" > Next </asp:LinkButton> <asp:linkbutton id= "End_button" runat= "Server" onclick= "End_button_click" > Last </asp:LinkButton>   per page <asp:textboxid= "Pagesize runat=" server "Text=" width= "30px" ></asp:TextBox> Bar current <asp:dropdownlistid= "pageing" runat= "Server" autopostback= "
True "onselectedindexchanged=" pageing_selectedindexchanged ></asp:DropDownList> page </div> Privatevoidpageing_databird (intvalue) {Pageing.Items.Clear (); Intzdatapage=convert.toint32 (Zpage.text); if (
zdatapage>0) {for (inti=1;i<=zdatapage;i++) {Pageing.Items.Add (i.tostring ());}} else {Pageing.Items.Add ("1");} if (Pageing.Items.FindByValue value. ToString ())!=null) Pageing.selectedvalue=value.
ToString (); if (zdatapage>1) {pageing.enabled=true; Intdatapageing=convert.toint32 (Pageing.selectedvalue); if (datapageing >1) {Start_button.
Enabled=true; Up_button.
Enabled=true; else {Start_button.
Enabled=false; Up_button.
Enabled=false; } if (Datapageing<zdatapage) {Down_button.
Enabled=true; End_button.
Enabled=true; else {Down_button.
Enabled=false; End_button.
Enabled=false; } else {Start_button.
Enabled=false; Up_button.
Enabled=false; Down_button.
Enabled=false; End_button.
Enabled=false;
Pageing.enabled=false; } protectedvoidstart_button_click (Objectsender,eventargse) {intdatapageing=1; if (Pageing.Items.FindByValue ( Datapageing. ToString ())!=null) pageing.selectedvalue=datapageing.
ToString ();
Databird (); } protectedvoidup_button_click (Objectsender,eventargse) {Intdatapageing=convert.toinT32 (Pageing.selectedvalue);
if (datapageing>1) datapageing--; if (Pageing.Items.FindByValue (datapageing). ToString ())!=null) pageing.selectedvalue=datapageing.
ToString ();
Databird (); } protectedvoiddown_button_click (Objectsender,eventargse) {Intdatapageing=convert.toint32 (Pageing.SelectedValue)
;
Intzdatapage=convert.toint32 (Zpage.text);
if (datapageing<zdatapage) datapageing++; if (Pageing.Items.FindByValue (datapageing). ToString ())!=null) pageing.selectedvalue=datapageing.
ToString ();
Databird (); } protectedvoidend_button_click (Objectsender,eventargse) {intzdatapage=convert.toint32 (Zpage.Text); if ( Pageing.Items.FindByValue (zdatapage. ToString ())!=null) pageing.selectedvalue=zdatapage.
ToString ();
Databird (); } protectedvoidpageing_selectedindexchanged (Objectsender,eventargse) {Databird ();} protectedvoiddatabird () {DC.
Setsql= "Select*fromadlistorderbycreatetimedesc"; Datatabledt=dc.
Getdatatable (0);
Pageddatasourcepds=newpageddatasource (); Pds. Datasource=dt.
DefaultView; Pds.
Allowpaging=true;intdatapagesize=10;
if (Convert.ToInt32 (pagesize.text) >0) Datapagesize=convert.toint32 (Pagesize.text); Pds.
Pagesize=datapagesize; Zcount.text=pds.
Datasourcecount.tostring (); Zpage.text = PDS.
Pagecount.tostring ();
intzpaging=1;
if (pageing.selectedindex>-1) Zpaging=convert.toint32 (Pageing.selectedvalue);
Pageing_databird (zpaging); Pds.
Currentpageindex=convert.toint32 (Pageing.selectedvalue)-1;
Listshow_repeater.datasource=pds;
Listshow_repeater.databind ();

 }

I believe this example can bring some inspiration to the ASP.net program design. Interested friends can further improve the example of this article, so that its function more perfect, the interface more beautiful.

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.