PDA

Click to See Complete Forum and Search --> : Datagrid Update Trouble [Resolved]


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").

MarkusJ_NZ
Jul 22nd, 2003, 11:56 PM
Hi, at the risk of stating the obvious you are not binding the datagrid in the page_load event are you? If so, are you doing the following;


if not page.isPostback then
' Bind your datagrid here
datagrid1.bind()
end if


Cheers
MarkusJ

Edneeis
Jul 23rd, 2003, 12:13 AM
No but I did have some other crap that was messing me up in the postback/load event. Fixed it now thanks.

Borry
Jul 31st, 2003, 08:24 AM
You had once a problem with your own code ??? ;) :D