In Asp.net 2.0, the crosspage function is added, that is, the first page can be easily accepted
For more information, see http://www.cnblogs.com/jackyrong/archive/2005/01/15/92472.html. Here, for example
For example, in a gridview, When you click the name of a person in the first column, and then jump to the second page, the specific information about this person is displayed on this page, this can be easily implemented using the cross page function.
Page A has a gridview:
<Asp: gridview id = "G" runat = "server"
Allowsorting = "true" autogeneratecolumns = "false" allowpaging = "true"
Pagesize = "50" onrowcommand = "g_onrowcommand">
<Columns>
<Asp: buttonfield headertext = "username"
Commandname = "select" datatextfield = "username"
Buttontype = "Link" </asp>
.....................
Write the following in the g_onrowcommand event:Code
Protected void g_onrowcommand (Object sender,
Gridviewcommandeventargs E)
{
If (E. commandname = "select ")
{
Int Index = convert. toint32 (E. commandargument );
Gridviewrow selectedrow = (gridviewrow) g. Rows [Index];
Linkbutton clickedlinkedbutton =
(Linkbutton) selectedrow. cells [0]. controls [0]);
Selectedusername = clickedbutton button. text;
Server. Transfer (".../../pages/search/usersummary. aspx", true );
}
}
Here, first obtain the record of the row selected by the user (obtain the index), and then obtain the connection content of the first column in The gridview, finally, use selectedusername to store the username in the record selected by the user .,
The selectedusername attribute is defined as follows:
Private string _ selectedusername;
Public String selectedusername
{
Get
{
Return _ selectedusername;
}
Set
{
_ Seletedusername = value;
}
}
Then in the second receiving page B. aspx, this design
<% @ Previouspagetype
Virtualpath = "~ /A .. aspx "%>
Protected void page_load (Object sender, eventargs E)
{
If (this. previouspage! = NULL)
{
Response. Write (this. previouspage. selectedusername );
}
}