控件绑定时触发事件(_RowDataBound事件)
protected void gvXw_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
e.Row.Cells[1].Text = Convert.ToDateTime(e.Row.Cells[1].Text).ToShortDateString();
}
}
本文介绍如何在ASP.NET中使用GridView控件的_RowDataBound事件来实现鼠标悬停时行背景颜色的变化效果,并展示如何格式化日期单元格。
333

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



