Hi,
I am a Delphi programmer and in Delphi the rows order of datagrid is given
by the sql query result, so, if I "order by" columns 1 and 2, the results
will appear ordered on the datagrid.
I am learning C# and I am trying to implement the Microsoft's suggested 5
layers design. This mean I am building BLL and DAL classes that will feed my
datagrid with DataTables.
My problem is: my "order by" clauses, so much optmized by database indexes
and ready for use, are ignored by the datagrid (or the datatable, I don't
know) and the result is sorted once again. How can I prevent this? Or, if
there isn't a solution for that, how can I order a datagrid by two or three
fields?
Thanks in advance
Marc Gravell - 16 May 2007 05:27 GMT
In COM, you sort the list. In Soviet Russia, the list sorts you! Or
more specifically, you need to get a view on the datatable (the
default [shared] view should be just fine), and set the sort string,
which can be comma delimited.
In the more generic sence (for *any* suitable data source, not just
DataTable), the IBindingListView.ApplySort() method does this job. The
poor relation is IBindingList.ApplySort() which only supports single
column.
Marc