HTML Code :
<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "default. aspx. CS "inherits =" gridpagertest. _ default "%> <br/> <% @ register Assembly =" gridpager "namespace =" gridpager "tagprefix =" GP "%> <br/> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <title> gridpager component test </title> <br/> <MCE: style type = "text/CSS"> <! -- <Br/> body {font-family:; font-size: 12px ;}</P> <p> --> </MCE: style> <style type = "text/CSS" mce_bogus = "1"> body {font-family:; font-size: 12px ;} <br/> </style> <br/> <LINK rel = "stylesheet" type = "text/CSS" href = "/gridpager/CSS/style1.css" mce_href = "gridpager /CSS/style1.css "/> <br/> <LINK rel =" stylesheet "type =" text/CSS "href ="/gridpager/CSS/shield.css "mce_href =" gridpager/ CSS/shield.css "/> <br/> </Head> <br/> <body> <br/> <Form ID = "form1" runat = "server"> <br/> <H2> Use System styles </H2> <br/> <GP: dataview id = "view1" runat = "server" width = "400px"> <br/> <columns> <br/> <GP: datafield field = "uname" Title = "name"> </GP: datafield> <br/> <GP: datafield field = "Birthday" Title = "Date of Birth" format = "{0: d}" readonly = "true"> </GP: datafield> <br/> <GP: editfield saveurl = "/ajax/gridpager. ashx? Type = Update "> </GP: editfield> <br/> <GP: deletefield saveurl ="/ajax/gridpager. ashx? Type = Delete "> </GP: deletefield> <br/> </columns> <br/> </GP: dataview> <br/> <input type = "button" value = "View selected ID" onclick = "alert (document. getelementbyid ('gp _ id '). value) "/> <br/> <input type =" button "value =" Save and modify "onclick =" saveedit () "/> </P> <p> <H2> Custom style (Extended repeater) </H2> <br/> <GP: gridpager id = "grid1" runat = "server"> <br/> <itemtemplate> <br/> <p> <% # eval ("uname") %>: <% # eval ("Birthday") %> </P> <br/> </itemtemplate> <br/> </GP: gridpager> </P> <p> <Div id = "gp_pager"> <% = grid1.pagerstring %> </div> <br/> </form> <br/> </body> <br/> </ptml>
C # code:
Using system; <br/> using system. collections. generic; <br/> using system. web; <br/> using system. web. ui; <br/> using system. web. UI. webcontrols; <br/> using gridpager; <br/> namespace gridpagertest <br/>{< br/> Public partial class _ default: system. web. UI. page <br/>{< br/> protected void page_load (Object sender, eventargs e) <br/>{< br/> string dbstring = system. configuration. configurationmanager. conne Ctionstrings [1]. connectionstring; <br/> dbstring = dbstring. replace ("$ dir $", appdomain. currentdomain. basedirectory); <br/> view1.connectionstring = dbstring; // The web is used if no value is specified. the connection string configured in config </P> <p> view1.table = "guid"; <br/> view1.fields = "*"; <br/> view1.pk = "ID "; <br/> view1.pagesize = 10; <br/> view1.pagenumber = 9; <br/> view1.pageindex = request ["page"]! = NULL? Int. parse (request ["page"]): 1; <br/> view1.showcheckbox = true; <br/> view1.showindex = true; <br/> // you can program the binding process. <br/> // view1.ondatabinding + = new gridpager. dataview. databindinghandler (viewemedidatabinding); <br/> view1.databind (); <br/> grid1.table = "b7-"; <br/> grid1.fields = "*"; <br/> grid1.pk = "ID"; <br/> grid1.pageindex = request ["page"]! = NULL? Int. parse (request ["page"]): 1; <br/> grid1.databind (); <br/>}< br/> protected void view1_databinding (Object sender, gridpager. dataitemeventargs e) <br/>{< br/> E. item. cells [2]. value + = ". edited "; <br/>}< br/>}
Page output:
Download source code:
Http://files.cnblogs.com/sqzhuyi/GridPagerTest.zip