M
Mr Newbie
I have a simple datagrid with three columns in it ID, LastName, FirstName.
I have Edit/Update columns enabled and in the update event I have the
following code. The problem is that the LastName and FirstName text boxes
return the unmodified values ( ones before I edit and updated them ). I know
what I am doing wrong must be stupid and simple but I cant see it.
Any ideas where my brain has gone ?
Mr N
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand
Dim dg As DataGrid = DirectCast(source, DataGrid)
Dim drow As DataRow
Dim myTableCell As TableCell
Dim LastName As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
Dim FirstName As TextBox = CType(e.Item.Cells(2).Controls(0), TextBox)
drow = Me.Ds1.Tables(0).Rows(e.Item.DataSetIndex)
drow("LastName") = LastName.Text
drow("FirstName") = FirstName.Text
Me.SqlDataAdapter1.Update(Ds1)
dg.DataBind()
End Sub
I have Edit/Update columns enabled and in the update event I have the
following code. The problem is that the LastName and FirstName text boxes
return the unmodified values ( ones before I edit and updated them ). I know
what I am doing wrong must be stupid and simple but I cant see it.
Any ideas where my brain has gone ?
Mr N
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.UpdateCommand
Dim dg As DataGrid = DirectCast(source, DataGrid)
Dim drow As DataRow
Dim myTableCell As TableCell
Dim LastName As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
Dim FirstName As TextBox = CType(e.Item.Cells(2).Controls(0), TextBox)
drow = Me.Ds1.Tables(0).Rows(e.Item.DataSetIndex)
drow("LastName") = LastName.Text
drow("FirstName") = FirstName.Text
Me.SqlDataAdapter1.Update(Ds1)
dg.DataBind()
End Sub