首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

动态加载GridViewRowEventHandler事件有关问题

2012-01-31 
动态加载GridViewRowEventHandler事件问题!RoomList(GridView)e.Item.Cells[0].FindControl( GridView2

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

热点排行