标题很不言自明。我有一个网格视图,当用户单击特定行时,我会在第一列中添加一个阴影。问题是,用户可以单击行上的任何位置,并添加阴影,但只有当用户单击链接(即第一列)时,才会在新的选项卡中打开该链接。如何将onclick事件仅添加到每行的第一列?
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Javascript function to call on row-click event
e.Row.Attributes.Add("onClick", "javascript:void SelectRow(this);");
}如果有帮助,我使用了示例here来实现SelectRow。
发布于 2012-11-29 05:41:58
将其添加到e.Row.Cells[0]中
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Attributes.Add("onClick", "SelectRow(this);");
}发布于 2012-11-29 05:42:15
尝试:
e.Row.Cells[0].Attributes.Add("onClick", "javascript:void SelectRow(this);");https://stackoverflow.com/questions/13614893
复制相似问题