Like Val mentioned, the grid is simply a UI aid for the bound object.
Whatever you do to it is done to the underlying table. Notice that
DataTables don't have a .Sort method. A DataView does. The table has a
defultView property that can be sorted. However, if you create a datatview
on a Datatable or use DefaultView and change the sort order (say by default
it was a column name CustID) to LastName if DataTable.Rows[0][0] before
equalled 1 ie CustID = 1,
then DataTable.Rows[0][0] will still be one after the sort.
However, the DataView will have a different sort order so if anything,
that's what you may want to go after. The bottom line is that Tables don't
sort per se, you can change their positions through refilling them with a
new select statement specifying a new sort order or some other (painful)
mechanism, but the order doesn't change. You can bind to a DataView instead
and manipulate the sort all you want. Then, when you change a vlaue in the
dataview (through code or through the grid) the change will pass through to
the underlying datatable.
HTH,
Bill
--
W.G. Ryan, eMVP
http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
subT said:
datagrid is bound to dataview..
the rows will sort when clicking on datagrid column headers...
however, selecting a row after sort reveals that the datatable still
maintains original order. rows were not sorted.