datalist tab (the codebehind part) Links: Andy.m Date: 2003-07-12 Popularity: 30using System; using System.Collections; using System.Configuration; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace cj168.Web {///
CalculateRecord (); lblrecordcount.text = RecordCount.toString (); if (! Page.ispostback) {dosearch (); currentpage = 0; viewState ["pageindex"] = 0; // How many pages of total Calculation PageCount = Recordcount / PageSize; if (RecordCount% PageSize> 0) PageCount = PageCount 1; lblPageCount.Text = PageCount.ToString (); ViewState [ "PageCount"] = PageCount;}}} // calculate total number of records public int CalculateRecord ( ) {CJ168.DataAccess.magsdb dosearch = new cj168.dataaccess.magsdb (); return dosearch.getsearchResultcount (txtsearch);} void dosearch () {Int StartIndex; int fromItem, toItem; // set imported from a final address StartIndex = CurrentPage * PageSize; cj168.DataAccess.MagsDB DoSearch = new cj168.DataAccess.MagsDB (); datalistSearchResult.DataSource = DoSearch.GetSearchResult (txtSearch, StartIndex, PageSize); datalistSearchResult.DataBind ( ); lbnNextPage.Enabled = true; lbnPrevPage.Enabled = true; if (CurrentPage == (PageCount-1)) lbnNextPage.Enabled = false; if (CurrentPage == 0) lbnPrevPage.Enabled = false; lblCurrentPage.Text = (CurrentPage 1) .toString (); fromItem = startIndex 1;