我有这个代码:
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim strPersonID As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("TextBox1"), TextBox).Text
Dim s As String=e.NewValues[1].ToString()
Dim strLastName As String = DirectCast(GridView1.Rows(e.RowIndex).FindControl("TextBox2"), TextBox).Text
Dim command As SqlCommand = New SqlCommand("updatetest", cn)
command.CommandType = CommandType.StoredProcedure
command.Parameters.AddWithValue("@pid", strPersonID)
command.Parameters.AddWithValue("@pfirstname", strLastName)
If cn.State = ConnectionState.Closed Then
cn.Open()
End If
command.ExecuteNonQuery()
If cn.State = ConnectionState.Open Then
cn.Close()
End If
End Sub
问题是事件 rowUpdating 正在返回旧值,所以我怎样才能获得更新的新值?请注意,程序未运行事件 RowUpdated
有什么帮助吗?
谢谢你 :)