|
-
Jul 22nd, 2003, 01:50 AM
#1
Datagrid Update Trouble [Resolved]
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.
VB Code:
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").
Last edited by Edneeis; Jul 23rd, 2003 at 12:15 AM.
-
Jul 22nd, 2003, 11:56 PM
#2
Hyperactive Member
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;
VB Code:
if not page.isPostback then
' Bind your datagrid here
datagrid1.bind()
end if
Cheers
MarkusJ
-
Jul 23rd, 2003, 12:13 AM
#3
No but I did have some other crap that was messing me up in the postback/load event. Fixed it now thanks.
-
Jul 31st, 2003, 08:24 AM
#4
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|