GridView实现双击选中当前行,并且取得当前行的数据!(或者取得当前行的ID) 5
2个回答
展开全部
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" +
e.Row.Cells[0].Text +
"','"+e.Row.Cells[1].Text+"','"+e.Row.Cells[2].Text+"','"+e.Row.Cells[3].Text+"','"+e.Row.Cells[4].Text+"','"+e.Row.Cells[5].Text+"','"+e.Row.Cells[6].Text+"','"+e.Row.Cells[7].Text+"','"+e.Row.Cells[8].Text+"')");
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" +
e.Row.Cells[0].Text +
"','"+e.Row.Cells[1].Text+"','"+e.Row.Cells[2].Text+"','"+e.Row.Cells[3].Text+"','"+e.Row.Cells[4].Text+"','"+e.Row.Cells[5].Text+"','"+e.Row.Cells[6].Text+"','"+e.Row.Cells[7].Text+"','"+e.Row.Cells[8].Text+"')");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询