in
ASP.NET
The dynamic load control is relatively simple. Here I will have the load on the user control. The typical is to contain a rapid event in the loaded user control. It is necessary to keep new data when returning.
First build a paging user control, because the previous articles are talking about these things, so they will change them directly, and the pagper code can view the above article 1, the article 2, below is part of the user control.
Public class pagingControl: system.Web.ui.userControl
{
PRIVATE INT pageCOUNT;
PRIVATE INT RecordCount;
......
Private Void Page_Load (Object Sender, System.EventArgs E)
{
IF (! page.ispostback)
{
DataGriddatabind ();
}
}
// Binding data
Private void DataGridDataBind ()
{
DataSet DS = GetCustomersdata (PageIndex, PageSize, Ref Recordcount, Ref PageCount);
THIS.DATAGRID1.VIRTUALITEMCOUNT = RecordCount;
THIS.DATAGRID1.DATASOURCE = DS;
THIS.DATAGRID1.DATABIND ();
SetPagingState ();
}
// Bind a new page
Private void lbtnnavigation_click (Object Sender, System.Eventargs E)
{
LinkButton BTN = (LinkButton) Sender;
Switch (btn.commandname)
{
Case "first":
PageIndex = 0;
Break;
Case "prev":
PageIndex = PageIndex - 1;
Break;
Case "Next":
PageIndex = PageIndex 1;
Break;
Case "Last":
PageIndex = PageCount - 1;
Break;
}
DataGriddatabind ();
}
......
}
On the above, we noticed that if the IF (! Page.ispostback) is determined in the page load event to prevent twice a binding when the return load is made, because the first time does not necessarily, it is finally determined by the binding in lbtnnaVigation_click.
Suppose PagingControl.ascx is the file name of the user control above, and the Page page file is in the same directory, below is the code of the ASPNetCommonPaging.aspx file. For dynamic loading, a PlaceHolder control is put on the page to load the previous user control.
The front desk document is as follows:
<% @ Page language = "c #" codebehind = "aspnetcommonpaging.aspx.cs" autoeventwireup = "false" inherits = "aspnetpaging.aspnetcommonpaging"%>%>
3C
// DTD HTML 4.0 Transitional // En ">