Author: zhoubin@mail.sdu.edu.cn
The time to do ASP is not short, but I am ASP.NET I am a newbie. A few days ago, I encountered a problem, requiring a more complex data format display, very difficult to implement with DataGrid, and later switch to the Repeater control. But this brings a new question: How do you paginize? Repeater has no built-in paging function. Later I tried to write one, I was lucky enough. In a hurry, it is definitely not perfect. Which expert is in the high meeting, I am willing to communicate with you (zhoubin@mail.sdu.edu.cn)
Protected system.Web.ui.WebControls.repeater Rptframework
Private void Page_load (Object Sender, System.Eventargs E) {
// Establish DataSet (this part is omitted)
RPTFramework.dataSource = mydataset; rptframework.database;
Session ["Page"] = 1;
// Hide I = 0 all entries in // hide int i = 0; for (i = 0; i // Repeater Control page size int INTPAGESIZE = 10; // RPTFramework control current page index (1 start) INT INTCURRENTPAGEINDEX = 0; IF (Request.QueryString ["Page"] == NULL || Convert.Toint32 (Request.QueryString ["Page"] == 0) {session ["Page" = 1;} else {session ["Page" ] = Convert.Toint32 (Request.QueryString ["Page"]); INTCURRENTPAGEINDEX = Convert.Toint32 (Session ["Page"]); // Previous button Shield IF (Convert.Toint 32 (session ["Page") == 1) {btnpre.enabled = false;} // RPTFramework control current cursor index (1 start) int INTCURRENTITEX = 1; INTCURRENTITEMINDEX = INTPAGESIZE * (INTCURRENTPAGEINDEX - 1) 1; // Next button Shield IF ((rptframework.Items.count - intcurrentItemIndex) // Set default view if (rptFramework.Items.Count> intPageSize) {for loading when the form (i = intCurrentItemIndex; i } // Take a smaller value in two values, but does not change the original value size private int GETMIN (INT A, INT B) {INT C; if (a> b) {c = B;} else {c = a; } Return C; // Click on the previous page button Private void btnpre_click (object sender, system.eventargs e) { INT INTPREPAGEINDEX = 2; IF (Convert.Toint32 (Session ["Page")! = 1) {INTPREPAGEINDEX = Convert.Toint32 (Session ["Page"]) - 1;} else {INTPREPAGEIDEX = 1;} Response.Redirect ("JGGK.ASPX? Page =" INTPREPAGEINDEX.TOSTRING ()); // Click Next button Private void btnnext_click (object sender, system.eventargs e) {int tentpageindex = convert.toint32 (session ["page"]) 1; response.redirect ("JGGK.ASPX? Page =" INTNEXTPAGEINDEX.TOSTOSTRING ());