admin管理员组文章数量:1393052
Title is pretty self-explanatory. I have a gridview, and when the user clicks on a particular row, I add a shadow to the first column. The problem is, the user can click anywhere on the row, and the shadow is added, but the link is only opened in a new tab if the user clicks on the link (i.e. first column). How do I add the onclick event to the first column of every row only?
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Javascript function to call on row-click event
e.Row.Attributes.Add("onClick", "javascript:void SelectRow(this);");
}
If it helps, I used the example here to implement SelectRow.
Title is pretty self-explanatory. I have a gridview, and when the user clicks on a particular row, I add a shadow to the first column. The problem is, the user can click anywhere on the row, and the shadow is added, but the link is only opened in a new tab if the user clicks on the link (i.e. first column). How do I add the onclick event to the first column of every row only?
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Javascript function to call on row-click event
e.Row.Attributes.Add("onClick", "javascript:void SelectRow(this);");
}
If it helps, I used the example here to implement SelectRow.
Share Improve this question asked Nov 28, 2012 at 21:39 FreakishlyFreakishly 1,5715 gold badges32 silver badges62 bronze badges 1-
javascript:void
is useless – epascarello Commented Nov 28, 2012 at 21:41
2 Answers
Reset to default 6Add it to e.Row.Cells[0]
instead
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Attributes.Add("onClick", "SelectRow(this);");
}
Try:
e.Row.Cells[0].Attributes.Add("onClick", "javascript:void SelectRow(this);");
本文标签:
版权声明:本文标题:c# - How can I add an onclick event to just the first column of a gridview and not the entire row? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744635109a2616777.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论