Results 1 to 5 of 5

Thread: datagird control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    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.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    How can we know what you are MISSING if we don't know what you have? Please post your code, no offence meant.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    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

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Posts
    471

    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
  •  



Click Here to Expand Forum to Full Width