Asp. NET aspnetpager paging code

Source: Internet
Author: User

Asp tutorial. net aspnetpager paging code
@ Page language = "c #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "test_default" stylesheettheme = "default" %>
<%... @ Register assembly = "aspnetpager" namespace = "wuqi. webdiyer" tagprefix = "webdiyer" %>
<Html xmlns = "http://www.111cn.net/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>

<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: datalist id = "datalist1" runat = "server">
<Itemtemplate>
Productname:
<Asp: label id = "productnamelabel" runat = "server" text = '<% # eval ("productname") %>'>
</Asp: label> <br/>
<Br/>
</Itemtemplate>
</Asp: datalist>
<Webdiyer: aspnetpager id = "pager1" runat = "server" onpagechanged = "changepage"> </webdiyer: aspnetpager>
</Div>
</Form>
</Body>
</Html>

<%

Using system;
Using system. data;
Using system. configuration;
Using system. collections;
Using system. web;
Using system. web. security;
Using system. web. ui;
Using system. web. ui. webcontrols;
Using system. web. ui. webcontrols. webparts;
Using system.web.ui.html controls;
Using cpp114.tools. oledb;
Using system. data. oledb;
Using wuqi. webdiyer;

Public partial class test_default: system. web. ui. page
...{
Protected oledbconnection conn = new oledbconnection ();
Protected oledbcommand cmd = new oledbcommand ();

Protected void page_load (object sender, eventargs e)
...{
If (! Ispostback )...{
Initdb ();
Conn. open ();
Cmd. commandtext = "select count (*) from t_product ";
Pager1.recordcount = (int00000000.exe cutescalar ();
Conn. close ();
Binddata ();
                      
        }

    }


 
// Initialize the connection object
   

Protected void initdb ()...{
Conn. connectionstring = oledbtool. myconnstr + server. mappath (oledbtool. mydbname );
Cmd. connection = conn;
    }

// Data binding

Protected void binddata ()...{
Initdb ();
Oledbdataadapter sda = new oledbdataadapter ("select * from t_product", conn );
Dataset ds = new dataset ();
// Sda. fill (ds, 10, 10, "temptbl ");
Sda. fill (ds, pager1.pagesize * (pager1.currentpageindex-1), pager1.pagesize, "temptbl ");
Datalist1.datasource = ds. tables ["temptbl"];
Datalist1.databind ();
    }

// Page flip event

Protected void changepage (object src, pagechangedeventargs e)
...{
Pager1.currentpageindex = e. newpageindex;
Binddata ();
    }   

}

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.