有一个GridView
第一列是个checkbox。现在每次单击行(绑定了onclick)会跳到详细页。
点checkbox也会跳到详细页。
如何不让他点击checkbox的时候也跳转?只有点击除了第一列的时候才会跳转?除了为每个cell绑定onclick(每个都绑定,假如有太都字段的话那不晕死了)的方法外还有什么方法?
第一列是个checkbox。现在每次单击行(绑定了onclick)会跳到详细页。
点checkbox也会跳到详细页。
如何不让他点击checkbox的时候也跳转?只有点击除了第一列的时候才会跳转?除了为每个cell绑定onclick(每个都绑定,假如有太都字段的话那不晕死了)的方法外还有什么方法?
CheckBox ck = (CheckBox)e.Row.Cells[0].FindControl("CheckBox1");
ck.Attributes.Add("onclick", "js1()");
//设置其他单元格的Click
e.Row.Cells[1].Attributes.Add("onclick", "test()");
e.Row.Cells[2].Attributes.Add("onclick", "test()");
e.Row.Cells[3].Attributes.Add("onclick", "test()");
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='E9E9E9'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");
e.Row.Attributes.Add("style", "cursor:pointer");
if(e.Row.Cells[0])//接下去要怎么写?
e.Row.Attributes.Add("onclick", "window.location.href='/Admin/ManagerReadMsg.aspx?ID=" + ((GridView)sender).DataKeys[e.Row.RowIndex].Values["ID"] + "'");
}
}
e.Row.Cells[0].Attributes.Add("onclick","");
if (e.Row.RowType == DataControlRowType.DataRow)
{
TableCellCollection cells = e.Row.Cells;
for(int i=1;i<cells.Count;i++)
e.Row.Cells[i].Attributes.Add("onclick", "window.open('Default.aspx')");
}