GridView事件问题,新手上路,急求!
来源:百度知道 编辑:UC知道 时间:2024/06/08 16:49:43
你好,RowDataBound 顾名思义,行绑定的时候触发的事件,由于GridView被加载的时候不是一下子出来的,就是一行一行的出来的,每出来一行,就触发一次RowDataBound事件,最终把整个GridView加载出来,你可以针对这个事件处理相应的事情,比如,在每一行添加OnMourseOver,OnMourseOut事件,这样GridView的每一行就有了这些事件。写的清楚一点吧:
双击RowDataBound事件进去后
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");
}
希望对你有帮助
gridview 可以在前台设置 用一个数据源
也可以在后台的代码中添加
public bool ExecAdapyerBind(GridView GridViewN, string SqlStr)
{
SqlConnection mycon = new SqlConnection("Data Source=.;Initial Catalog=gbgl;Integrated Security=True");
myc