protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
        string tea = this.GridView1.DataKeys[e.RowIndex].ToString();
    }
是怎么回事,是不是还哪里需要设置

解决方案 »

  1.   

      protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
            {
                gv.EditIndex = e.RowIndex;
                int id = int.Parse(gv.DataKeys[e.RowIndex].Value.ToString());
              
                gv.EditIndex = -1;
                BindData();
            }
    protected void gv_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            //没有e.RowIndex
        }
      

  2.   

     gv.EditIndex = e.;
    这句话 怎么出不来呢 RowIndex还是不能调用啊
      

  3.   

    protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
      {
      string tea = this.GridView1.DataKeys[e.Row.RowIndex].ToString();
      }
      

  4.   

    在给GridView绑定数据时,你给GridView设置主键了吗?
    GridView1.DataSource="";
    GridView1.DataKeyNames=new string[]{"id"};(这里必须和数据库中的字段保持一致)
    GridView1.DataBind();
      

  5.   

    这个e.RowIndex 在每个事件里面都有不同的,C/S和B/S又有不同。先弄清楚你触发的事件
      

  6.   

    先不论我方法是否正确,为什么RowIndex  怎么都出不来了?
    错误 1 “System.Web.UI.WebControls.GridViewUpdatedEventArgs”并不包含“RowIndex”的定义 D:\杂项\Visual Studio 2005\WebSites\StudentManage\TeacherManage.aspx.cs 55 33 D:\...\StudentManage\
    总是出错
      

  7.   


    protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
      string tea = new DataKey(e.Keys).Value.ToString();
    }
      

  8.   

    你的代码是用的RowUpdated啊,重新贴下你的代码吧
      

  9.   

    楼主代码完全是copy来的
    不用想的。
      

  10.   

    是 
    protected void GridView1_RowUpdated(object sender, GridViewUpdateEventArgs e)
    不是
    protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    我刚解决!