问题:
在page1.aspx中datagrid 中有五个字段分别是:字段1(主键)、字段2、字段3、字段4、字段5,现在点击button 把要把字段1、字段2传递到page2.aspx页面去
请问在C#中如何做?
请大家帮助
谢谢!
在page1.aspx中datagrid 中有五个字段分别是:字段1(主键)、字段2、字段3、字段4、字段5,现在点击button 把要把字段1、字段2传递到page2.aspx页面去
请问在C#中如何做?
请大家帮助
谢谢!
<ItemTemplate>
<a href='page2.aspx?id=<%# DataBinder.Eval(Container, "DataItem.字段1")%>&字段2=<%# DataBinder.Eval(Container, "DataItem.字段2")%>' target="_blank"><%# DataBinder.Eval(Container, "DataItem.title") %></a>
</ItemTemplate>
{
if(e.Item.ItemType == ListItemType.Item||e.Item.ItemType ==ListItemType.AlternatingItem)
e.Item.Cells[6].Text = "<a href=Detail2.aspx?vis_time="+e.Item.Cells[0].Text+"&group="+e.Item.Cells[2].Text+" target=_blank><font color=blue>查看详情</font></a>";
}
string acces = DataBinder.Eval(e.Item.DataItem,"字段").ToString();
或者
string acces = ((DataRowView)e.Item.DataItem)["字段"].ToString();
取,e.Item.Cells[0].Text有的时候会包含 很麻烦
2.还可以用Session 等对象.
3.如果是在DataGrid的模板列通过链接传递,可以用多参数链接列:前台DataGrid中的模板列部分代码:
<ItemTemplate>
<asp:Label runat="server"
Text='<%# GetHyperLinkURL(DataBinder.Eval(Container,"DataItem.CusNO").ToString(),DataBinder.Eval(Container, "DataItem.AutoID").ToString())%>'>
</asp:Label>
</ItemTemplate>
后台:
protected string GetHyperLinkURL(string strCusNo,string strID)
{
return @"http://index.aspx?CusNO="+strCusNo+"&ID="+strID";
}
Server.Transfer();传过去
.Net技术讨论群14272327,欢迎爱好c#和asp.net的同志加入~队伍正在不断壮大中...