Datagrid sorting programatically - How?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Junkguy

    #1

    Datagrid sorting programatically - How?


    Hi all,

    I need some advice on how to sort the contents of a datagrid from code. The
    issue I have is a client that wants the datagrid to show its rows in "entry"
    order (i.e. the order in which rows appear in the database) after performing a
    new search to find some rows. This is actually how a datagrid will initially
    show its rows, but after the user clicks a column header, the datagrid will
    forever after show rows sorted according to that column.

    There seems to be no way to get back to the "entry" order after that. I need a
    way to reset the default ordering from the code, so that each search the user
    does will revert to the unsorted display. Looking in the datagrid
    documentation provides no help at all. In my particular usage, I have the
    datagrid tied to a dataset.

    Thanks to any who can help.

    --
    Junkguy
  • Junkguy

    #2
    Re: Datagrid sorting programatically - Never Mind?

    In article <junkguy-8B3B06.12464718 102003@news-server-fe-01.columbus.rr. com>,
    Junkguy <junkguy@columb us.rr.com> wrote:
    [color=blue]
    > I need some advice on how to sort the contents of a datagrid from code.[/color]

    Ok, nevermind I got it:

    Datagrid dg;
    ...
    DataTable dt = (DataTable) dg.DataSource;
    dt.DefaultView. Sort = "";


    At least it seems to work. Somebody let me know if this is a bad idea.

    Thanks.

    --
    Junkguy

    Comment

    Working...