[英]Adding Links to grid cells(autogenerated gridview using C#), and getting information based on what user clicked
我从列表用户ID自动生成一列值; 这是使用存储的Oracle过程生成的,该过程使用输入字符串(如果... id像“%string%”一样返回refcursor); 因此,UserId列表在网格中看起来像这样:
用户身份
1111555
2222111
3331113
...
现在基于搜索参数lenth,该列可能从1条记录到10条记录(如果UserID.count> 10则显示错误消息),因此每次我们在网格中看到不同的值
我的问题是如何在这些自动生成的UserID(位于单元格中)上放置链接,当用户单击其中一个链接时,我可以获取所选的id(1111555),并使用它向用户显示另一个网格:)
这可能很简单...
您可以这样处理OnRowDataBound
事件:
protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
// Display the company name in italics.
e.Row.Cells[0].Text = "<a href=\"page.aspx?id=" + e.Row.Cells[0].Text + "\">"+e.Row.Cells[0].Text+"</a>";
}
}
其中UserID是网格中的第一列(Cell [0])。 这是标记:
<asp:gridview id="GridView1"
autogeneratecolumns="true"
allowpaging="true"
onrowdatabound="GridView1_RowDataBound"
runat="server">
</asp:gridview>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.