|
-
Nov 14th, 2002, 03:03 PM
#1
Thread Starter
Hyperactive Member
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.
-
Nov 14th, 2002, 03:36 PM
#2
How can we know what you are MISSING if we don't know what you have? Please post your code, no offence meant.
-
Nov 14th, 2002, 03:48 PM
#3
Thread Starter
Hyperactive Member
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
-
Nov 14th, 2002, 04:12 PM
#4
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
-
Nov 14th, 2002, 04:18 PM
#5
Thread Starter
Hyperactive Member
it is bound
i did the binding in properties window.
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
|