锅盖头4电影免费观看:data grid更新时出现了问题,很急,请各位高手看看啊

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 14:28:50
我在用datagrid更新数据时,运行时没什么错误,但是在textbox中修改数据后,点击更新时数据却没什么变化.不知道怎么回事?这是我再 mfdg_UpdateCommand的代码.麻烦各位高手帮我看看哪里出错了,帮我改改,谢谢!!!!
???? Dim firstname As String
????Dim lastname As String
Dim CurrentTextBox As TextBox
CurrentTextBox = e.Item.Cells(1).Controls(1)
firstname = CurrentTextBox.Text
CurrentTextBox = e.Item.Cells(2).Controls(1)
lastname = CurrentTextBox.Text

If conn.State = ConnectionState.Closed Then
conn.Open()

End If
Dim str As String = "UPDATE mfuser SET firstName = '" & firstname.Replace("''", "''") & "',lastName = '" & lastname.Replace("''", "''") & "' WHERE ID= '" & e.Item.Cells(0).Text & "'"

Dim cmd As New OleDb.OleDbCommand(str, conn)
cmd.Connection = conn
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
mfdg.EditItemIndex = -1
With Me.mfdg()
.DataSource = dst
.DataBind()

End With

不见得是这里的问题,你看看你在page_load里是否加了!ispostback,如果没有,加上再试一次看看