-
datagird control
hi,
I have a datagrid on my web form, the grid has Edit button for each row,s o the user can edit info in grid rows.
my problem is that after the editing and hitting Update button, the text goes back to its original, my change does't get saved. Do you know what i missed here? thanks.
-
How can we know what you are MISSING if we don't know what you have? Please post your code, no offence meant.
-
thanks
Here is my code:
Private Sub grdProduct_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdProduct.UpdateCommand
Dim newData As String
Dim aTextbox As TextBox
Dim pid
aTextbox = e.Item.Cells(1).Controls(0)
newData = aTextbox.Text
Me.Response.Write(newData)
'update data source
pid = Me.grdProduct.DataKeys(CInt(e.Item.ItemIndex))
strCMD = "update tblProducts set Name = '" & newData & "' where productIndex = " & pid
Me.Response.Write(strCMD)
'create db connection
Me.OleDbConnection1.Open()
cmd.Connection = Me.OleDbConnection1
cmd.CommandText = strCMD
cmd.ExecuteNonQuery()
End Sub
-
Are you not binding to a dataset in your grid? If so why not give the dataadapter used to fill it the updatecommand and have it do it. I think that is how it tracks the changes and shows them in the grid as well.
http://msdn.microsoft.com/library/de...oedititems.asp
-
it is bound
i did the binding in properties window.