How to use it on the page on the page on the page, how do you use these?
First of all,
List page implementation
IpageInfo interface:
Public class rolelist: system.web.ui.page, ipageInfo
Then for each
DataGrid instantiation
DataInfo object:
Protected DataInfo DataInfo = New DataInfo ("Role");
Next, write some processing
DataGrid status code, I am using the properties:
#Region data grid status information
Private system.collections.hashtable searchParams
{
get
{
IF (ViewState ["searchParams"]! = NULL)
{
Return (HashTable) ViewState ["SearchParams"];
}
Else
Return NULL;
}
set
{
ViewState ["SearchParams"] = Value;
}
}
Private system.collections.hashtable OtherDataparams
{
get
{
IF (ViewState ["OtherDataParams"]! = null)
{
Return (Hashtable) ViewState ["OtherDataParams"];
}
Else
Return NULL;
}
set
{
ViewState ["OtherDataParams"] = Value;
}
}
Private int currentpage
{
get
{
Return myDataGrid.currentpageindex;
}
set
{
MyDataGrid.currentpageIndex = value;
MyDataGrid.databind ();
NaviGaterole.currentpage = mydatagrid.currentpageIndex 1;
NaviGaterole.totalpages = mydatagrid.pagecount;
}
}
Private string sortexpression
{
get
{
Return DSSystem.Role.defaultView.Sort;
}
set
{
DSSystem.Role.defaultView.sort = value;
MyDataGrid.databind ();
NaviGaterole.totalpages = mydatagrid.pagecount;
}
}
Private string itemid
{
get
{
IF (MyDataGrid.selected "= 0)
{
Return mydatagrid.datakeys [myDataGrid.selected ".toString ();
}
Else
Return NULL;
}
set
{
INT pageIndex = mydatagrid.currentpageindex;
BOOL FIND = FALSE;
For (int J = 0; j { MyDataGrid.currentpageIndex = j; MyDataGrid.database (); for (int i = 0; i { IF (MyDataGrid.DataKeys [i] .tostring () == value) { Find = true; Break; } } } IF (Find == False) { MyDataGrid.currentpageIndex = pageIndex; MyDataGrid.databind (); } NaviGaterole.currentpage = mydatagrid.currentpageIndex 1; NaviGaterole.totalpages = mydatagrid.pagecount; } } #ndregion in Take out the data of the previous page in PageLoad, pay attention, pay attention, from the front page Server.Transfer method: IpageInfo pointInfo = null; / / Remove the information of the previous page and save the data grid status Try { PageInfo = (ipageInfo) context.handler; } Catch {} IF (PageInfo! = NULL) { IF (PageInfo.uaryParams! = NULL) Otherparams = pageInfo.uaryparams; IF (PageInfo.datainfos! = null) { / / Save all DataGrid information DataInfos = pageinfo.datainfos; / / Remove the current data of DataGrid IF (pageinfo.datainfos [datainfo.dataname]! = null) { DataInfo = PageInfo.datainfos [DataInfo.dataname]; } } } Take the data out and then natural is processing, I set the value of the previous attributes, and there are many kinds of methods, which is not described here. Implementation of ipageInfo, When the DataInfos property is updated to update each page DataGrid DataInfo information to reflect the nearest changes: Public String Pagename { get { Return "rolelist"; } } Public HashTable Otherparams { get { IF (ViewState]! = null) { Return (Hashtable) ViewState ["Otherparams"]; } Else Return NULL; } set { ViewState ["OtherParams"] = VALUE } } Public DataInfolist DataInfos { get { / / Update data grid status information DataInfolist DataInfolist; IF (ViewState ["DataInfos"]! = NULL) DataInfolist = (DataInfolist) ViewState ["DataInfos"]; Else DataInfolist = new datainfolist (); DataInfo.currentPage = CurrentPage; DataInfo.itemid = itemid; DataInfo.othesaParams = OtherDataParams; DataInfo.searchParams = SearchParams; DataInfo.sortexpression = sortexpression; DataInfolist [DataInfo.dataname] = DATAINFO; Return DataInfolist; } set { ViewState ["DataInfos"] = Value; } } Jump to other pages (such as the detailed page): Server.Transfer ("RoledgeTail.aspx"); For the Detail page, it will be relatively simple because there is basically no Datinfo update problem, which is designed to modify the itemid: Also implement the interface first: Public Class RoledTail: System.Web.ui.page, ipageInfo Then define two variables, a preserved data, a definition of the current data category, that is, to operate which DataInfo instance: Protected ipageInfo; protected string dataname = "role"; PageLoad Remove the previous page data and process the current item data: Try { PageInfo = (ipageInfo) context.handler; } Catch { } // Remove the current item ID IF (PageInfo! = Null && PageInfo.datainfos! = NULL) { DataInfos = pageinfo.datainfos; } // Take detailed data IF (DataInfos! = Null && DataInfos [DataName] .Itemid! = null) Getitemdata (); Else Getnulldata (); Implementation of the interface: Public String Pagename { get { Return "rodingetail"; } } Public DataInfolist DataInfos { get { IF (ViewState ["DataInfos"]! = NULL) { Return (DataInfolist) ViewState ["DataInfos"]; } Else Return NULL; } set { ViewState ["DataInfos"] = Value; } } Public HashTable Otherparams { get { IF (ViewState]! = null) { Return (Hashtable) ViewState ["Otherparams"]; } Else Return NULL; } set { ViewState ["OtherParams"] = VALUE } } #ndregion Jump to other pages (such as returning List): Server.Transfer ("RoleList.aspx"); This way we need to be implemented.