动态加载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();//注数据也显示在页面上。