gridview中,用一按钮绑定字段,单击按钮后,跳转其它页,并传值!!! 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <asp:GridView> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button ID="A" Text ='<%#Eval("A") %>' runat="server" PostBackUrl="~/Default.aspx?id=100" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> 建议用linkButton title属性绑定字段,将按钮的CommandName属性设置为Select,protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int id = Convert.ToInt32(GridView1.SelectedDataKey[0]);//获得该记录的ID 既然获得该行记录的ID那你想怎么传就怎么传了! } //绑定链接 protected void CPSGridView1_RowDataBound(object sender, GridViewRowEventArgs e) { string plant = string.Empty; string sloc = string.Empty; plant = e.Row.Cells[1].Text.Trim(); sloc = e.Row.Cells[2].Text.Trim(); e.Row.Cells[3].Text = "<a href=\"javascript:OpenPage('" + plant + "','" + sloc + "')\">" + plant + "</a>"; } //FrozenColumn(); }// JScript File function OpenPage(plant,sloc) { var page="SSTDBDetail.aspx?Plant="+plant+"&SLoc="+sloc; window.open (page, 'newwindow', 'height=500, width=1000, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=n o, status=no') } 前台:<asp:LinkButton ID="lbtnReSubmit" runat="server" CommandName="Submit" CommandArgument=' <%# Eval("Id")%>' Text=" 链接 " />后台:if (e.CommandName == "Submit") //链接 { string Id = e.CommandArgument.ToString(); Response.Redirect("test1.aspx?id=" + Id); } 事件:protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 关于jquery uploadify实现传值的问题。 ajax 无刷新 问题 类文件里面为什么不能写这样的代码 如何用js判断TreeView至少要选择一个节点? 为什么有的图片能显现出来,有的出不来???? 好心人告诉我下ASP.NET分页吧 网上哪里有测试短信平台的工具啊 UltraWebGrid分层出问题:索引超出了数组界限 用Array.sort(),如何按文件名排序? 有关xml数据显示! 请问如何查询出windows所有本地用户的信息 总价格
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="A" Text ='<%#Eval("A") %>' runat="server" PostBackUrl="~/Default.aspx?id=100" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
{
int id = Convert.ToInt32(GridView1.SelectedDataKey[0]);//获得该记录的ID
既然获得该行记录的ID那你想怎么传就怎么传了!
}
//绑定链接
protected void CPSGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string plant = string.Empty;
string sloc = string.Empty;
plant = e.Row.Cells[1].Text.Trim();
sloc = e.Row.Cells[2].Text.Trim();
e.Row.Cells[3].Text = "<a href=\"javascript:OpenPage('" + plant + "','" + sloc + "')\">" + plant + "</a>";
}
//FrozenColumn();
}
// JScript File function OpenPage(plant,sloc)
{
var page="SSTDBDetail.aspx?Plant="+plant+"&SLoc="+sloc;
window.open (page, 'newwindow', 'height=500, width=1000, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=n o, status=no')
}
<asp:LinkButton ID="lbtnReSubmit" runat="server" CommandName="Submit" CommandArgument=' <%# Eval("Id")%>' Text=" 链接 " />
后台:
if (e.CommandName == "Submit") //链接
{
string Id = e.CommandArgument.ToString();
Response.Redirect("test1.aspx?id=" + Id);
}
事件:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)