protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//for (int i = 0; i < GridView1.Rows.Count; i++)
//{
if (e.Row.RowType==DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
//}
if (e.Row.RowIndex != -1)
{
int id = e.Row.RowIndex + 1;
e.Row.Cells[0].Text = id.ToString();
}
}
GridView实现自动编号及鼠标移到GridView某一行时改变该行的背景色
最新推荐文章于 2022-02-25 19:38:17 发布
本文介绍了一个ASP.NET中GridView控件的自定义样式设置方法,通过RowDataBound事件为每一行添加鼠标悬停效果,并实现了行索引的动态显示。
883

被折叠的 条评论
为什么被折叠?



