主题:[讨论]datagrid的编辑更新不了,怎么回事
Dim strIDkey As String = (Me.DataGrid1.DataKeys(e.Item.ItemIndex)).ToString()
Dim newColor As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim strUpdate As String = "update 颜色表 set 颜色名称 = @newColor where 编号 = @newID "
conn = New OleDbConnection(connStr)
conn.Open()
Dim myCmd As OleDbCommand = New OleDbCommand(strUpdate, conn)
myCmd.Parameters.Add("@newID", OleDbType.VarChar, 10).Value = strIDkey.Trim()
myCmd.Parameters.Add("@newColor", OleDbType.VarChar, 50).Value = newColor.Trim()
Dim i As Integer = 0
i = myCmd.ExecuteNonQuery()
Me.DataGrid1.EditItemIndex = -1
BindData()
conn.Close()
请兄弟们帮我看看,为什么更新不了数据库里的字段,运行时却没出错的,我在onload事件中也加了 If (Not IsPostBack) Then
BindData()
End If
代码了,急啊,谢谢各位了