The advantage of Asp.net is to quickly build applications. For some of the most basic data addition, deletion, modification, and paging event or style settings, you can write a virtual method in the parent class for the subclass to call, if the subclass needs to derive a change or simply not use a method of the parent class on the basis of the template, you only need to override the method of the parent class. 
 
 
 
  experiment  Code  is as follows : 
 first, the template class is abstracted and inherited from the page class;   copy Code   the code is as follows: public class template: system. web. UI. page 
{< br> protected override void onload (eventargs e) 
{< br> base. onload (E); 
 If (! Ispostback) 
{< br> datarefresh (); 
}< BR >}< br> protected virtual void datarefresh () 
{< BR >}< br> protected virtual void grid_init (Object sender, eventargs e) 
{< br> var grid = sender as gridview; 
 grid. allowpaging = true; 
 grid. pagesize = 10; 
 grid. pagersettings. mode = pagerbuttons. numericfirstlast; 
}< br> protected virtual void grid_pageindexchanging (Object sender, gridviewpageeventargs e) 
{< br> var grid = sender as gridview; 
 grid. pageindex = E. newpageindex; 
 datarefresh (); 
}< BR >}
 
  then an instance that inherits the template class ;   copy Code   the code is as follows: <% @ page Language =" C # "autoeventwireup =" true "codebehind =" child. aspx. CS "inherits =" webtest. child "%> 
  
 
 
  
   
 
 
 
  
 
 
 
   
 
 
 
  
 
 
 
Finally, it is the key background code implementation. Here we assume that you need to modify the number of displays per page and the paging style of the grid;Copy codeThe Code is as follows: public partial class child: Template
{
Protected override void datarefresh ()
{
Grid. datasource = new logdao (). getlogsbyyearmonth ("2012", "10 ");
Grid. databind ();
}
Protected override void grid_init (Object sender, eventargs E)
{
Base. grid_init (sender, e );
Grid. pagersettings. mode = pagerbuttons. nextpreviusfirstlast;
Grid. pagesize = 15;
}
}
 
 
 
The above is only a way of thinking. If there is any mistake, I hope all netizens will criticize and correct it.