Edneeis
Jul 22nd, 2003, 01:50 AM
Well I'm experiencing something funky. For some reason the UpdateCommand event is showing the data as it was before it was edited. I have it working on another project, but in that one I know the fieldnames at designtime (not that it sould matter). Now in another project if I set a breakpoint in the UpdateCommand then go and edit say some text from "Weak" to "Weakling" and press update it still says that the control reads "Weak"???? I don't get it. Anyone else having this trouble.
Private Sub dgCurrent_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCurrent.UpdateCommand
Dim ds As DataSet = ViewState("Data")
Dim cnt As Integer
Dim cntMax As Integer = ds.Tables(0).Rows(e.Item.ItemIndex).ItemArray.Length - 1
If cntMax < 0 Then cntMax = 0
For cnt = 0 To cntMax
ds.Tables(0).Rows(e.Item.ItemIndex)(cnt) = DirectCast(e.Item.Cells(cnt + 2).Controls(0), TextBox).Text
Next
dgCurrent.EditItemIndex = -1
ViewState("Data") = ds
SaveData()
LoadData()
End Sub
The part that says 'DirectCast(e.Item.Cells(cnt + 2).Controls(0), TextBox).Text' should return "Weakling" but still returns the value as if it were not edited ("Weak").
Private Sub dgCurrent_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCurrent.UpdateCommand
Dim ds As DataSet = ViewState("Data")
Dim cnt As Integer
Dim cntMax As Integer = ds.Tables(0).Rows(e.Item.ItemIndex).ItemArray.Length - 1
If cntMax < 0 Then cntMax = 0
For cnt = 0 To cntMax
ds.Tables(0).Rows(e.Item.ItemIndex)(cnt) = DirectCast(e.Item.Cells(cnt + 2).Controls(0), TextBox).Text
Next
dgCurrent.EditItemIndex = -1
ViewState("Data") = ds
SaveData()
LoadData()
End Sub
The part that says 'DirectCast(e.Item.Cells(cnt + 2).Controls(0), TextBox).Text' should return "Weakling" but still returns the value as if it were not edited ("Weak").