【发布时间】:2014-02-14 23:38:52
【问题描述】:
我知道这个问题已经被问过一百次了,但是我在实现不同的解决方案时遇到了困难。我需要从 asp.net Web 应用程序 C# 中的网格视图中检索选定的行。我已经完成了数据绑定。我没有'不想使用编辑/更新按钮或复选框/单选按钮,只是通过单击行来选择它。请帮助,我有点卡住了,我不想实现基于 javascript 的解决方案。谢谢。
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("OnMouseOver", "this.style.cursor='pointer';this.style.textDecoration='underline';");
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.ToolTip = "Click on select row";
e.Row.Attributes["OnClick"] = Page.ClientScript.GetPostBackClientHyperlink(this.SingleSelectGrid, "Select$" + e.Row.RowIndex);
LinkButton selectbutton = new LinkButton()
{
CommandName = "Select",
Text = e.Row.Cells[0].Text
};
e.Row.Cells[0].Controls.Add(selectbutton);
e.Row.Attributes["OnClick"] = Page.ClientScript.GetPostBackClientHyperlink(selectbutton, "");
}
【问题讨论】:
-
请不要在标题中使用标签。
标签: c# asp.net gridview web row