Get updated values in Gridview

Discussion in 'ASP .Net' started by Joe Blauth, Jun 13, 2008.

  1. Joe Blauth

    Joe Blauth Guest

    Hi all,

    I was running into a problem with a gridview under ASP.net. What I am trying
    to do is binding the DataSource dynamically in a way that enables me to edit
    the rows in the Gridview. This is basically running alright except of the
    fact that when I switch to "edit" in a row inside the Gridview and edit the
    value and hit "update" I don't find a way to retrieve the changed values.

    Here's what I did:
    I placed a DataGrid control on my aspx page and bind it dynamically to a
    datatable like the following:

    With Me.DataGrid
    .DataSource = _oClient.GetCalculationDetails(1) 'this retrieves a
    datatable
    .AutoGenerateEditButton = True
    .DataBind()
    End With

    the RowEditing-Event is filled with

    Me.DataGrid.EditIndex = e.NewEditIndex
    DataBind()

    Then, in the RowUpdating-Event I am accessing the cell values with

    With sender.Rows(e.RowIndex)
    _oClient.SetCalculationDetails( _
    CType(.Cells(1).Controls(0).Text, Long), _
    .Cells(2).Controls(0).Text.ToString, _
    0, "")
    End With

    unfortunately I only receive the old values and had no chance to retrieve
    the changed - which are obviously the displayed - values. How can I do that/
    what's my mistake here ? Even the e.NewValues/ OldValues Collections appear
    to be empty.

    Any help highly appreciated - thanks in advance!

    Joe.
     
    Joe Blauth, Jun 13, 2008
    #1
    1. Advertising

  2. Joe Blauth

    Joe Blauth Guest

    i forgot to mention that the datatable consists of a single table query like
    SELECT col1, col2 FROM dbo.tbl_Test WHERE id = x

    Greets,
    Joe.


    "Joe Blauth" <> schrieb im Newsbeitrag
    news:g2sgs0$51f$...
    > Hi all,
    >
    > I was running into a problem with a gridview under ASP.net. What I am
    > trying to do is binding the DataSource dynamically in a way that enables
    > me to edit the rows in the Gridview. This is basically running alright
    > except of the fact that when I switch to "edit" in a row inside the
    > Gridview and edit the value and hit "update" I don't find a way to
    > retrieve the changed values.
    >
    > Here's what I did:
    > I placed a DataGrid control on my aspx page and bind it dynamically to a
    > datatable like the following:
    >
    > With Me.DataGrid
    > .DataSource = _oClient.GetCalculationDetails(1) 'this retrieves a
    > datatable
    > .AutoGenerateEditButton = True
    > .DataBind()
    > End With
    >
    > the RowEditing-Event is filled with
    >
    > Me.DataGrid.EditIndex = e.NewEditIndex
    > DataBind()
    >
    > Then, in the RowUpdating-Event I am accessing the cell values with
    >
    > With sender.Rows(e.RowIndex)
    > _oClient.SetCalculationDetails( _
    > CType(.Cells(1).Controls(0).Text, Long), _
    > .Cells(2).Controls(0).Text.ToString, _
    > 0, "")
    > End With
    >
    > unfortunately I only receive the old values and had no chance to retrieve
    > the changed - which are obviously the displayed - values. How can I do
    > that/ what's my mistake here ? Even the e.NewValues/ OldValues Collections
    > appear to be empty.
    >
    > Any help highly appreciated - thanks in advance!
    >
    > Joe.
    >
     
    Joe Blauth, Jun 13, 2008
    #2
    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:
    693
    =?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:
    540
    =?Utf-8?B?T3plcg==?=
    Jun 12, 2004
  3. Steve Kershaw
    Replies:
    1
    Views:
    2,314
    David R. Longnecker
    Sep 21, 2007
  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:
    416
    Dmitry Korolyov
    Sep 22, 2003
  5. Chris Mahoney

    Get updated values from DataGrid

    Chris Mahoney, Sep 19, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    138
    Elton Wang
    Sep 20, 2005
Loading...

Share This Page