DataList page

xiaoxiao2021-03-06  75

Private void page_load (object sender, system.eventargs e) {pagesize = 10; // Show total page number PageCount = getpgcount (); lbpagecount.text = "Total" pagecount.toString () "page"; if (! Page.ispostback) {ViewState ["PageIndex"] = 0; binddata ();} else {currentpage = (int) ViewState ["pageIndex"];}}

#Region data bind private void binddata () {string strcon = "provider = microsoft.jet.oledb.4.0; data source =" server.mappath (".//penhui.mdb"); OLEDBConnection Con = New OLEDBCONNECTION (strcon); con.open ();

string str_sel = "SELECT user_tab.username, guestbook_tab.guestid, guestbook_tab.zhuti, guestbook_tab.content, guestbook_tab.systime, guestbook_tab.recontent FROM guestbook_tab, user_tab where guestbook_tab.userid = user_tab.userid order by guestbook_tab.systime desc";

OLEDBDataAdapter Da = New OLEDBDataAdapter (Str_sel, Con);

DataSet DS = New DataSet (); DA.FILL (DS, (CurrentPage * Pagesize), Pagesize, "Guest"); mylist.dataroup = ds.tables ["guest"]. Defaultview; mylist.database ();

Da.dispose (); con.close ();

} #endregion

// Computing total record number protected int = "provike = microsoft.jet.oledb.4.0; data source =" server.mappath ("..// Penhui.mdb"); OLEDBConnection conn = new OLEDBCONNECTION (STRCON); conn.open ();

string selstr = "select count (*) as icount from guestbook_tab"; OleDbCommand com = new OleDbCommand (selstr, conn); OleDbDataReader dr = com.ExecuteReader (); if (dr.Read ()) {int icount = Int32.Parse (DR ["iCount"]. toString ()); lbrecordcount.text = "Total" ICount.Tostring () "Sum Record"; Dr.Close (); conn.close (); return ket;} else { Return 0;}}}} // Total pages protected () {INT jlcount = {INT jlcount = rscount (); int pgcount; if (jlcount% pagesize == 0) {pgcount = (jlcount / pagesize);} else {pgcount = jlcount / pagesize) 1;} return pgcount;} // page private void link_pre_Click (object sender, System.EventArgs e) {currentpage = (int) ViewState [ "pageindex"]; if (currentpage> 0) currentpage-- ; ViewState [ "pageindex"] = currentpage; BindData ();} // next private void link_next_Click (object sender, System.EventArgs e) {currentpage = (int) ViewState [ "pageindex"]; if (currentpage <(pagecount -1)) CURRENTPAGE ; VI EWSTATE ["PageIndex"] = CurrentPage; Binddata () ;;}

转载请注明原文地址:https://www.9cbs.com/read-120520.html

New Post(0)