aligning datagrid with datasource

Discussion in 'ASP .Net' started by Jan Limpens, Nov 7, 2003.

  1. Jan Limpens

    Jan Limpens Guest

    hi folks,

    which is the best way to get to the datasource/row via a bound datagrid?

    my datagrid is bound to a dataview.
    when i select a button in the grid i want easy access to the
    corresponding datarowview in the dataview.

    until now my best bet is to get the datakey from the
    datagrid.SelectedItem, sort my view by the key´s field and then use
    dataview.Find() to get the row. but thats horribly cubersome and sorts
    my view in a way i do not like it to be sorted!

    i am very sure there must be a much better method which i haven't found
    yet - please tell me :)

    thanks
    jj
     
    Jan Limpens, Nov 7, 2003
    #1
    1. Advertisements

  2. Hi Jan,
    it seems you need to use the
    System.Web.UI.WebControls.DataGridCommandEventArgs parameter passed to the
    event handler: it has an Item property which in turn has a DataItem property
    that references the DataRowView you need to access.

    Hope it helps,
    Luca

    "Jan Limpens" <-this.here> wrote
    in message news:...
    > hi folks,
    >
    > which is the best way to get to the datasource/row via a bound datagrid?
    >
    > my datagrid is bound to a dataview.
    > when i select a button in the grid i want easy access to the
    > corresponding datarowview in the dataview.
    >
    > until now my best bet is to get the datakey from the
    > datagrid.SelectedItem, sort my view by the key´s field and then use
    > dataview.Find() to get the row. but thats horribly cubersome and sorts
    > my view in a way i do not like it to be sorted!
    >
    > i am very sure there must be a much better method which i haven't found
    > yet - please tell me :)
    >
    > thanks
    > jj
    >
     
    Luca Bertoldi, Nov 7, 2003
    #2
    1. Advertisements

  3. Jan Limpens

    Jan Limpens Guest

    it does, thanks!

    Luca Bertoldi wrote:

    > Hi Jan,
    > it seems you need to use the
    > System.Web.UI.WebControls.DataGridCommandEventArgs parameter passed to the
    > event handler: it has an Item property which in turn has a DataItem property
    > that references the DataRowView you need to access.
    >
    > Hope it helps,
    > Luca
     
    Jan Limpens, Nov 7, 2003
    #3
    1. Advertisements

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. Dave

    Datagrid - Aligning Items

    Dave, Nov 12, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    616
  2. matthew schouppe
    Replies:
    3
    Views:
    2,565
    Scott Allen
    Apr 30, 2004
  3. =?Utf-8?B?SmVubmlmZXI=?=

    aligning datagrid columns

    =?Utf-8?B?SmVubmlmZXI=?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    6,187
    =?Utf-8?B?SmVubmlmZXI=?=
    Nov 22, 2004
  4. nemo
    Replies:
    1
    Views:
    5,056
    S. Justin Gengo
    Sep 16, 2005
  5. Jan Limpens

    aligning datagrid with datasource

    Jan Limpens, Nov 7, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    218
    Jan Limpens
    Nov 7, 2003
  6. Vijaya

    Aligning the controls in the item template of the datagrid

    Vijaya, Dec 15, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    288
    Kelly Leahy
    Dec 18, 2003
  7. matthew schouppe

    DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource

    matthew schouppe, Apr 29, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    376
    Scott Allen
    Apr 30, 2004
  8. Jan Limpens

    aligning datagrid with datasource

    Jan Limpens, Nov 7, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    189
    Jan Limpens
    Nov 7, 2003
Loading...