读书人

动态加载GridViewRowEventHandler事件

发布时间: 2012-01-31 21:28:42 作者: rapoo

动态加载GridViewRowEventHandler事件问题!

RoomList = (GridView)e.Item.Cells[0].FindControl( "GridView2 ");
RoomList.DataSource = RangInfo.GetDataSet();
RoomList.DataBind();//注数据也显示在页面上。

RoomList.RowDataBound += new GridViewRowEventHandler(RoomList_DataBound);
e.Item.Attributes.Add( "onmouseover ", "this.style.backgroundColor= '#E4EDF9 ' ");//以执行可以颜色可以改变。

protected void RoomList_DataBound(object sender, GridViewRowEventArgs e)
{
Response.Write( "没有执行 ");
}


事件:RoomList.RowDataBound += new GridViewRowEventHandler(RoomList_DataBound); 这句为什么就不行呢!!

[解决办法]
加载的时机不对

[解决办法]
放在DataBind() 前面

RoomList.RowDataBound += new GridViewRowEventHandler(RoomList_DataBound);

RoomList.DataSource = RangInfo.GetDataSet();
RoomList.DataBind();//注数据也显示在页面上。

读书人网 >asp.net

热点推荐