HI I have a datagrid that is not updating - when you click the "Update " link, it just reverts back to the data it got at Page Load and comes out of edit mode. I have tried the if not Page.IsPostBack - but it made no difference (Unless I put it in the wrong place) - it is for an ASP.NET web form. Also, I am a beginner. Can someone have a look at the code, please ? This is for the update part of it - the edit and cancel part seem to work ok.
thanks.
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()
Dim ID, DayOfTheWeek, Whereabouts As String
ID = CType(e.Item.Cells(1).Controls(0), TextBox).Text
DayOfTheWeek = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Whereabouts = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim r As DataSet1.tbljfoleyRow
r = DataSet11.tbljfoley.FindByID(key)
r.DayOfTheWeek = DayOfTheWeek
r.Whereabouts = Whereabouts
r.ID = ID
SqlDataAdapter1.Update(DataSet11)
DataGrid1.DataBind()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
thanks.
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()
Dim ID, DayOfTheWeek, Whereabouts As String
ID = CType(e.Item.Cells(1).Controls(0), TextBox).Text
DayOfTheWeek = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Whereabouts = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim r As DataSet1.tbljfoleyRow
r = DataSet11.tbljfoley.FindByID(key)
r.DayOfTheWeek = DayOfTheWeek
r.Whereabouts = Whereabouts
r.ID = ID
SqlDataAdapter1.Update(DataSet11)
DataGrid1.DataBind()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()