Get updated values from DataGrid

Discussion in 'ASP .Net Datagrid Control' started by Chris Mahoney, Sep 19, 2005.

  1. Hi

    I have a DataGrid, with Edit links in each row. The Edit button works, the
    user can change the values. But I can't get updating to work.

    <asp:datagrid id="Content" runat="server" OnUpdateCommand="Content_Update"
    OnCancelCommand="Content_Cancel" OnEditCommand="Content_Edit">
    <Columns>
    <asp:EditCommandColumn EditText="Edit" UpdateText="Update"
    CancelText="Cancel" />
    </Columns>
    </asp:datagrid>

    Sub Content_Update(ByVal sender As Object, ByVal e As
    DataGridCommandEventArgs)
    Dim txt1 As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
    Dim txt2 As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
    etc.

    My problem is that txt1 and txt2 end up with the original values, not the
    new ones that have been entered by the user. I've looked for a PostBack
    function but there doesn't seem to be one. How can I get the updated values?

    Thanks
    Chris
     
    Chris Mahoney, Sep 19, 2005
    #1
    1. Advertising

  2. Sorry, I'm an idiot, ignore this :)

    Chris

    "Chris Mahoney" <> wrote in message
    news:...
    > Hi
    >
    > I have a DataGrid, with Edit links in each row. The Edit button works, the
    > user can change the values. But I can't get updating to work.
    >
    > <asp:datagrid id="Content" runat="server" OnUpdateCommand="Content_Update"
    > OnCancelCommand="Content_Cancel" OnEditCommand="Content_Edit">
    > <Columns>
    > <asp:EditCommandColumn EditText="Edit" UpdateText="Update"
    > CancelText="Cancel" />
    > </Columns>
    > </asp:datagrid>
    >
    > Sub Content_Update(ByVal sender As Object, ByVal e As
    > DataGridCommandEventArgs)
    > Dim txt1 As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
    > Dim txt2 As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
    > etc.
    >
    > My problem is that txt1 and txt2 end up with the original values, not the
    > new ones that have been entered by the user. I've looked for a PostBack
    > function but there doesn't seem to be one. How can I get the updated
    > values?
    >
    > Thanks
    > Chris
    >
    >
     
    Chris Mahoney, Sep 19, 2005
    #2
    1. Advertising

  3. Chris Mahoney

    Elton Wang Guest

    No, you are smart to fingure it out yourself.


    "Chris Mahoney" <> wrote in message
    news:...
    > Sorry, I'm an idiot, ignore this :)
    >
    > Chris
    >
    > "Chris Mahoney" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I have a DataGrid, with Edit links in each row. The Edit button works,

    the
    > > user can change the values. But I can't get updating to work.
    > >
    > > <asp:datagrid id="Content" runat="server"

    OnUpdateCommand="Content_Update"
    > > OnCancelCommand="Content_Cancel" OnEditCommand="Content_Edit">
    > > <Columns>
    > > <asp:EditCommandColumn EditText="Edit" UpdateText="Update"
    > > CancelText="Cancel" />
    > > </Columns>
    > > </asp:datagrid>
    > >
    > > Sub Content_Update(ByVal sender As Object, ByVal e As
    > > DataGridCommandEventArgs)
    > > Dim txt1 As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
    > > Dim txt2 As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
    > > etc.
    > >
    > > My problem is that txt1 and txt2 end up with the original values, not

    the
    > > new ones that have been entered by the user. I've looked for a PostBack
    > > function but there doesn't seem to be one. How can I get the updated
    > > values?
    > >
    > > Thanks
    > > Chris
    > >
    > >

    >
    >
     
    Elton Wang, Sep 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmV3YXNwcw==?=
    Replies:
    0
    Views:
    715
    =?Utf-8?B?TmV3YXNwcw==?=
    Jun 12, 2004
  2. =?Utf-8?B?T3plcg==?=

    DataGrid.UpdateCommand I can't get updated values

    =?Utf-8?B?T3plcg==?=, Jun 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    550
    =?Utf-8?B?T3plcg==?=
    Jun 12, 2004
  3. =?Utf-8?B?TWFyeUE=?=

    Retrieve the updated values from datagrid

    =?Utf-8?B?TWFyeUE=?=, Aug 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,898
    =?Utf-8?B?TWFyeUE=?=
    Aug 13, 2005
  4. Dmitry Korolyov

    Datagrid not updated during delete, but updated during insert and update

    Dmitry Korolyov, Sep 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    439
    Dmitry Korolyov
    Sep 22, 2003
  5. Dan

    DataGrid: OnUpdateCommand - getting the updated values

    Dan, Aug 18, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    169
Loading...

Share This Page