This data source, divided into two parts, one is to adjust the data from the data class, and then operate the paging parameters and page paging assistance in this data source! There are three controls in front to control pages, a drop-down list, two linkButton!
Seeing more than class data operations
Http://thcjp.cnblogs.com/archive/2006/06/18/428775.html This article
The following fill () method call is very simple, and you want to write Fill (), you want to rebound, huh! But be sure to write, for example, after the page is executed!
Below is the DS method in the DB class
public
Static
DataTable DS
String
QUE)
{// Returns a data sheet loaded with SQL, OLEDBConnection Con = ODB.CON (); OLEDBDataAdapter oda = new oledbdataadapter (); oda.selectcommand = new oledbcommand (que, con); dataset ds = new dataset () Oda.fill (DS, "THC"); Return DS.Tables ["THC"];
The data source used below is the above.
Private
Void
Fill ()
{// Make a method, because the page will have multiple bindings // Here you set a hidden Label, with the current page index int Cup = Convert.Toint32 (PagelBl.Text); PageLbl.Text); PageLBL.Text PagedDataSource (); // New One Paging Data Source Ps.DataSource = ODB.DS ("Select * from Guest ORDER BY ID DESC"). DefaultView; // Send a SQL statement into it, determine the data source of the data source, a bit Bar, huh, huh, huh ps.allowpaging = true; // Allow paging ps.pagesize = 2; // Setting the number of ps.currentpageIndex = CUP-1; if (! Ispostback) {// Decision page Whether the page is loaded For (int i = 1; i <= ps.pagecount; i ) {// loop out pageddl.Items.add (i.tostring ());}} // The following mainly controls whether the up and down reflection button is started PageUp.enabled = true; if (ps.isfirstpage) {// If it is the forefront page, the last page is not available to the page, which is not available;} if (ps.islastpage) {// If it is Last page, the next page is not available, the page is not available;} // Set the page number drop-down menu The currently selected value Pageddl.SelectedItem.text = Cup.Tostring (); // Finally can be bound to DataList DataList1.DataSource = PS; DAT Alist1.datakeyfield = "id"; datalist1.database ();} The following is the processing of flipping events
protected
Void
Pageddl_selectedIndexchanged
Object
Sender, Eventargs E)
{// Page Code drop-down menu event Pagelbl.text = pagedl.selectedItem.text.toString (); fill ();
protected
Void
Pagedown_click
Object
Sender, Eventargs E)
{// Next Event PagelBl.Text = Convert.TOString (Convert.Toint32 (PagelBl.Text) 1); Fill ();}
protected
Void
Pageup_click
Object
Sender, Eventargs E)
{// Previous Event Pagelbl.Text = Convert.TOString (Convert.Toint32 (PagelBl.Text) -1); Fill ();}