日期:2014-05-20  浏览次数:20397 次

GridView的更新按钮问题[分不够可以再给]
点击编辑后,我更新里面的内容
然后点击更新,可是就是更新不了

更新按钮的代码
protected   void   GVeditor_RowUpdated(object   sender,   GridViewUpdatedEventArgs   e)
        {
              try
                {
                        string   cj   =   ((TextBox)e.NewValues[5]).Text;//成绩
                        string   kccj   =   ((TextBox)e.NewValues[6]).Text;//考查成绩
                        string   xk   =   ((TextBox)e.NewValues[1]).Text;//学生ID
                        string   km   =   ((TextBox)e.NewValues[4]).Text;//科目

                        string   cmdtext   =   "update   成绩   set   成绩= ' "   +   cj   +   " ',考查成绩= ' "   +   kccj   +   " '   where   成绩.学生= ' "   +   xk   +   " '   and   成绩.科目   in   (select   ID   from   科目   where   科目.科目= ' "   +   km   +   " ') ";
                        SqlConnection   sqlconn   =   new   SqlConnection(sqllink.sqlconn());
                        sqlconn.Open();

                        SqlCommand   sqlcomm   =   new   SqlCommand(cmdtext,   sqlconn);
                        sqlcomm.ExecuteNonQuery();
                        sqlconn.Close();
                }
                catch   (Exception   ex)
                {
                        Response.Write(ex.Message);
                }
                this.GVeditor.DataSource   =   gvBind();
                this.GVeditor.DataBind();      
                GVeditor.EditIndex   =   -1;
}

////////////////////HTML代码
      <asp:GridView   ID= "GVeditor "   runat= "server "   Width= "100% "   Height= "72px "   AutoGenerateColumns= "False "   OnRowCancelingEdit= "GVeditor_RowCancelingEdit "   OnRowEditing= "GVeditor_RowEditing "   OnRowUpdating= "GVeditor_RowUpdating "   OnRowUpdated= "GVeditor_RowUpdated "   >
                                <Columns>
                                        <asp:BoundField   DataField= "学号 "   HeaderText= "学号 "   ReadOnly= "True "   />