DataGrid sort when Editing

Discussion in 'ASP .Net Datagrid Control' started by Steve, Mar 9, 2005.

  1. Steve

    Steve Guest

    This may be a common question, however I didn't find any posts on the issue.
    When you are editing a row of a datagrid, and then you sort the datagrid, the
    edititemindex stays the same, which means that you are now editing a
    different item (though the same physical row of the datagrid). How can you
    make it so that you are still editing the same data after you sort? As it
    is, I am simply clearing the edititemindex. (By the way, this issue also
    applies when using the selecteditemindex.)

    Your help is appreciated, thank you.
    Steve, Mar 9, 2005
    #1
    1. Advertising

  2. Steve

    Elton Wang Guest

    Hi Steve,

    I suppose you have to implement your own code to solve the
    problem. You may use following logic.

    When sorting
    If edititemindex <> -1 then
    Find PK data from edit item
    Endif
    Sort data source and assign it to datagrid
    Find index from PK data
    Assign edititemindex = the index
    Call datagrid.DataBind


    HTH

    Elton Wang


    >-----Original Message-----
    >This may be a common question, however I didn't find any

    posts on the issue.
    >When you are editing a row of a datagrid, and then you

    sort the datagrid, the
    >edititemindex stays the same, which means that you are

    now editing a
    >different item (though the same physical row of the

    datagrid). How can you
    >make it so that you are still editing the same data after

    you sort? As it
    >is, I am simply clearing the edititemindex. (By the way,

    this issue also
    >applies when using the selecteditemindex.)
    >
    >Your help is appreciated, thank you.
    >.
    >
    Elton Wang, Mar 9, 2005
    #2
    1. Advertising

  3. Steve

    Scott M. Guest

    You'll have to know the index of the row in the dataset. Unfortunately, the
    DataSetIndex property doesn't provide this accurately after you have sorted,
    so you'll need to find the record manually in the dataset and then get its'
    index. You can use the Select method and pass a SQL like search criteria to
    help you find the record in the DataSet.


    "Steve" <> wrote in message
    news:...
    > This may be a common question, however I didn't find any posts on the
    > issue.
    > When you are editing a row of a datagrid, and then you sort the datagrid,
    > the
    > edititemindex stays the same, which means that you are now editing a
    > different item (though the same physical row of the datagrid). How can
    > you
    > make it so that you are still editing the same data after you sort? As it
    > is, I am simply clearing the edititemindex. (By the way, this issue also
    > applies when using the selecteditemindex.)
    >
    > Your help is appreciated, thank you.
    Scott M., Mar 13, 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. Eugene
    Replies:
    0
    Views:
    476
    Eugene
    Sep 28, 2004
  2. nobody
    Replies:
    0
    Views:
    529
    nobody
    Jun 1, 2004
  3. Replies:
    0
    Views:
    575
  4. uk00121

    Editing a datagrid nested within another datagrid

    uk00121, Apr 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    138
    uk00121
    Apr 19, 2004
  5. Navin
    Replies:
    1
    Views:
    672
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page