DataGrid Update.Command event handler

Discussion in 'ASP.NET / ASP.NET Core' started by burleys, Jan 11, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi putting up data in a data grid. Bound and using Templated Columns with EditItemTemplate sections for each column.

    The named textboxes come up fine when going into edit mode, but when I try to retrieve the data from them to update the record, I just get the original data that was in the record and not the edited data from the text boxes.

    Here's my code in the update.command handler...




    Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand


    Dim pnID As Integer = CType(DataGrid1.DataKeys(e.Item.ItemIndex), Integer)


    Dim pnTB As TextBox = CType(e.Item.FindControl("EditPseudonym"), TextBox)


    Dim cnTB As TextBox = CType(e.Item.FindControl("EditCaeNo"), TextBox)


    Dim pn As String = pnTB.Text.Trim


    Dim cn As String = cnTB.Text.Trim


    DA.UpdatePseudoNyms(pnID, pn, cn) ' update the database using dataAcess class instatiated as DA


    DataGrid1.EditItemIndex = -1


    PopulatePersonFields(GetID) 'rebinds the datagrid


    End Sub





    I've used a Response.write directly after the dim pn and dim cn lines and the data they are picking up is the original un-edited data.


    Simon
     
  2. OK I got it.





    I was re-binding on postback, so lost the edited data.





    Thanks for 'If not IsPostback' !
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page