how to inforce sorting on datagrid before populating

  • Thread starter Thread starter Adel
  • Start date Start date
A

Adel

Hello guys
Does any one know about how to inforce sorting on a
specific coloumn in a datagrid before populating it ?
Thanks in advance
 
Use an ORDER BY clause in your SQL query so that your
query results will be ordered the way you want before you
populate the datagrid.
 
Try something like this (for the DataTable or DataView) to control the sort
by code. I do this after the datasource has been bound.


dataTable1.DefaultView.Sort =
dataTable1.DefaultView.Table.Columns[0].ColumnName;
dataView1..Sort = dataView1.Table.Columns[0].ColumnName + " DESC";


HTH,
Eric Cadwell
http://www.origincontrols.com
 
Back
Top