datalist中嵌套gridview后 OnRowDataBound 事件无效,以下代码变的没有作用。protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#cccccc';d=this.style.color;this.style.color='#009999'");//backgroundColor='#95B8FF'#aca899
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;this.style.color=d");
            Label myLabel = (Label)e.Row.Cells[2].FindControl("myLabel");
            myLabel.Text = Convert.ToString(e.Row.RowIndex + 1);
        }
    }

解决方案 »

  1.   

    不知加断点调试过吗??  datalist绑定时的时间 加上 你看看 是否这个的绑定是否执行啦
      

  2.   

    朋友,试下 在datalist 绑定前,GridView1.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound);
      

  3.   

    sorry, 说错了,应该是在GridView1绑定前