asp.net的几种经典的页面传值方法

第一种是写在代码里的

View Code
   
     
1 Response.Redirect( " adminUpdate.aspx?userName= " + gvAdminInFo.SelectedRow.Cells[ 1 ].Text.ToString().Trim() + " &userJiaoSe= " + gvAdminInFo.SelectedRow.Cells[ 2 ].Text.ToString().Trim() +
2 " &userStart= " + gvAdminInFo.SelectedRow.Cells[ 3 ].ToString().Trim());

在下一个页面接收值的时候

View Code
   
     
1 txtUserName.Text = Request[ " userName " ].ToString().Trim();
2 txtUserJiaose.Text = Request[ " userJiaoSe " ].ToString().Trim();
3 txtUseruserStart.Text = Request[ " userStart " ].ToString().Trim();

2 第二种是在页面里写的

View Code
   
     
1 < asp:HyperLink id = HyperLink1 runat = " server " NavigateUrl = ' <%# DataBinder.Eval(Container.DataItem, "SendUserName","SendSMsg.aspx?QID={0}") %> ' Text = ' <%# DataBinder.Eval(Container.DataItem, "SendUserName") %> ' Target = " _blank " >
2 </ asp:HyperLink >

在程序接收的时候

View Code
   
     
1 txtUserName.Text = Request[ " SendUserName " ].ToString().Trim();

3 如果有多个值的话,还可以这样传

View Code
   
     
1 < asp:HyperLink ID = " HyperLink2 " NavigateUrl = ' <%#DataBinder.Eval(Container.DataItem, "ID","~/admin/passwordUpdate.aspx?ID={0}")+DataBinder.Eval(Container.DataItem, "UserName","&UserName={0}")%> ' runat = " server " > 重置 </ asp:HyperLink >

本文章转载http://www.cnblogs.com/sufei,很不错哦。永远都顶这个博客。学习了,呵呵

你可能感兴趣的:(asp.net)