DataGrid1_UpdateCommand 执行后数据是原来的,根本没有变?为何?
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim kaohao As TextBox = CType(e.Item.Cells(3).Controls(0), TextBox)
Dim xingming As TextBox = CType(e.Item.Cells(4).Controls(0), TextBox)
Dim xingbie As TextBox = CType(e.Item.Cells(5).Controls(0), TextBox)
Dim xuexiao As TextBox = CType(e.Item.Cells(6).Controls(0), TextBox)
Dim kaoqu As TextBox = CType(e.Item.Cells(7).Controls(0), TextBox)
Dim kaoshi As TextBox = CType(e.Item.Cells(8).Controls(0), TextBox)
Dim zuoweihao As TextBox = CType(e.Item.Cells(9).Controls(0), TextBox)
Dim chengji As TextBox = CType(e.Item.Cells(10).Controls(0), TextBox)
Dim item As Integer = CInt(e.Item.Cells(2).Text)
Dim sqlStr As String
sqlStr = "UPDATE kaoshitable SET 考号='" & Trim(kaohao.Text) & "',姓名='" & Trim(xingming.Text) & "',性别='" & Trim(xingbie.Text) & "',所在学校='" & Trim(xuexiao.Text) & "'"
sqlStr = sqlStr & ",考区='" & Trim(kaoqu.Text) & "',考室='" & Trim(kaoshi.Text) & "',座位号='" & Trim(zuoweihao.Text) & "',考试成绩='" & Trim(chengji.Text) & "'"
sqlStr = sqlStr & " WHERE 编号 = '" & item & "'"
Label1.Text = sqlStr
Dim AddData As OleDbCommand = New OleDbCommand(sqlStr, P_con)
AddData.ExecuteNonQuery()
P_con.Close()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub