Referencing Datagrid Rows while Datagrid is Sorted

Discussion in 'ASP .Net Web Controls' started by MrMike, May 20, 2005.

  1. MrMike

    MrMike Guest

    I see this question raised often elsewhere, but I haven't yet found an
    answer. When a datagrid is sorted, referencing a specific row is a problem.
    In my applications I frequently use datagrids and I must tell my users "If
    you are going to edit/update/delete a record from a datagrid, make sure you
    don't have it sorted first because you'll perform the action on the wrong
    record."

    Is there a way to work around the problem of sorting a datagrid and then
    referencing it's records? Thanks.
     
    MrMike, May 20, 2005
    #1
    1. Advertising

  2. Hi Mike,

    It's no problem to let them sort still and also let them edit the data. Look
    in the DataGridCommandEventArgs of the update event to get the DataGrid row
    instead of EditItemIndex to get the updates for your DataTable. This way your
    DataGrid can be more flexable:

    private void DataGrid1_UpdateCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    string updatedText = e.Item.Cells[0].Text;
    }

    Cheers,
    Steve Goodyear
     
    Steve Goodyear, May 21, 2005
    #2
    1. Advertising

  3. MrMike

    MrMike Guest

    Hi Steve,

    Thank you very much for that valuable information!!

    "Steve Goodyear" wrote:

    > Hi Mike,
    >
    > It's no problem to let them sort still and also let them edit the data. Look
    > in the DataGridCommandEventArgs of the update event to get the DataGrid row
    > instead of EditItemIndex to get the updates for your DataTable. This way your
    > DataGrid can be more flexable:
    >
    > private void DataGrid1_UpdateCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    > {
    > string updatedText = e.Item.Cells[0].Text;
    > }
    >
    > Cheers,
    > Steve Goodyear
     
    MrMike, May 23, 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. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,243
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. helpful sql
    Replies:
    0
    Views:
    820
    helpful sql
    May 19, 2005
  3. Arjen Hoekstra
    Replies:
    0
    Views:
    565
    Arjen Hoekstra
    Aug 2, 2005
  4. Matt B
    Replies:
    6
    Views:
    468
    Matt B
    Oct 8, 2005
  5. Jason James

    Rows the rows of a grid view?

    Jason James, Aug 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    398
    Jason James
    Aug 10, 2006
Loading...

Share This Page