Datagrid sorting programatically - How?

Datagrid sorting programatically - How?

Post by Junkgu » Mon, 20 Oct 2003 01:48:23

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.


1. DataGrid RowNumber when the user 'sorts' the DataGrid

2. Referencing Datagrid Rows while Datagrid is Sorted

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

Is there a way to work around the problem of sorting a datagrid and then
referencing it's records? Thanks.

3. datagrid sort - 3 col in file - 2 col in datagrid - fails?

4. How do you map DataGrid rows to it's DataSource when sorting a DataGrid?

5. Hellp Finishing Sort using IBindingList with DataGrid - "" (0/1) 8.1 KBytes yEnc

6. [Datagrid,web form]: How the get the correct row values after sorting datagrid by header

7. Need Help Determining DataGrid Column Selected for Sort using IBindingList - (0/1)

8. DataGrid Sort - Not sorting a button column

9. How to sort datagrid and keep the bound data as sorted?

10. Creating Datagrid Programatically

11. Set headertext in datagrid programatically

12. Programatically adding a control (DataGrid)?

13. Set headertext in datagrid programatically

14. selecting multiple rows in a datagrid programatically