Privateconststringviewstatecurrentpageindex = "CurrentPageIndex";
Privateconststringviewstaterecordcount = "RecordCount";
Publicdelegatevoidpagechangedhandle ();
Publiceventpagechangedhandle onpagechanged;
Returnconvert.toint32 (Ddlpagesize.selectedvalue);
Publicintcurrentpageindex
Viewstate[viewstatecurrentpageindex] = value;
if (Viewstate[viewstatecurrentpageindex] ==null)
Viewstate[viewstatecurrentpageindex] = 1;
Returnconvert.toint32 (Viewstate[viewstatecurrentpageindex]);
if (Viewstate[viewstaterecordcount] ==null)
Viewstate[viewstaterecordcount] = 0;
Returnconvert.toint32 (Viewstate[viewstaterecordcount]);
Viewstate[viewstaterecordcount] = value;
Privateinttotalnumberofpages
Returnrecordcount% PageSize = 0? Recordcount/pagesize: (recordcount/pagesize) + 1;
Protectedvoidpage_load (Objectsender, EventArgs e)
Protectedvoidlabfirstpage_click (Objectsender, EventArgs e)
Protectedvoidlabpreviouspage_click (Objectsender, EventArgs e)
Protectedvoidlabnextpage_click (Objectsender, EventArgs e)
Protectedvoidlablastpage_click (Objectsender, EventArgs e)
CurrentPageIndex = totalnumberofpages;
Protectedvoidbtngo_click (Objectsender, EventArgs e)
Boolisnum = Int32.TryParse (txtpagenum.text,outpagenum);
CurrentPageIndex = Math.min (Pagenum, totalnumberofpages);
Protectedvoidddlpagesize_selectedindexchanged (Objectsender, EventArgs e)
Protectedoverridevoiddatabind (boolraiseondatabinding)
Base. DataBind (raiseondatabinding);
Labcurrentpageindex.text = Currentpageindex.tostring ();
Labtotalnumberofpages.text = Totalnumberofpages.tostring ();
Labrecordcount.text = Recordcount.tostring ();
Privatevoidsetnavigateenabled ()
Txtpagenum.text = Currentpageindex.tostring ();
Labfirstpage.enabled =true;
Labpreviouspage.enabled =true;
Labnextpage.enabled =true;
Lablastpage.enabled =true;
Labfirstpage.cssclass = "Font-blue";
Labpreviouspage.cssclass = "Font-blue";
Labnextpage.cssclass = "Font-blue";
Lablastpage.cssclass = "Font-blue";
if (CurrentPageIndex = 1)
Labfirstpage.enabled =false;
Labpreviouspage.enabled =false;
Labfirstpage.cssclass = "Gray";
Labpreviouspage.cssclass = "Gray";
if (CurrentPageIndex = = totalnumberofpages)
Labnextpage.enabled =false;
Lablastpage.enabled =false;
Labnextpage.cssclass = "Gray";
Lablastpage.cssclass = "Gray";
Labfirstpage.enabled =false;
Labpreviouspage.enabled =false;
Labfirstpage.cssclass = "Gray";
Labpreviouspage.cssclass = "Gray";
Labnextpage.enabled =false;
Lablastpage.enabled =false;
Labnextpage.cssclass = "Gray";
Lablastpage.cssclass = "Gray";