Order by Clause....

  • Thread starter Thread starter Smith John
  • Start date Start date
S

Smith John

I am creating a table object inside a dataset and attaching that to the

datagrid.



DataGrid1.DataSource = myDataset.Tables("myTable")

DataGrid1.DataBind()



Is there anyway before I bind the data to the grid can I sort the data
defining a column.

Like order by criteria in SQL.

Thanks,

Smith
 
dim dv as DataView = myDataSet.Tables("myTable")
dv.Sort = "MyColumn ASC"
DataGrid1.DataSource = dv
DataGrid1.DataBind()

Karl
 
Thank you Karl for the soultion.
This step involves converting the data to dataview which involves few CPU
cycles.
Before implementing this I want to make sure there is no other method which
is build in the dataset or dataset table is available.
Thanks,
Smith
 
I have set Option Explicit On
I am getting the error for the below line.
dim dv as DataView = myDataSet.Tables("myTable")

I am using .Net Framework 1.1.
Please advice.
Thanks
Smith
 
heh..cpu cycles....those couple milliseconds will really come back to haunt
you....well, rest assured, when you do XXXXX.DataSource = DataSet/DataTable,
it automatically fetches the DefaultView from those (ie, you are always
binding to a DataView), so there is no performance penalty. Frankly, you
want things to be ordered but don't expect to spend any cpu cycles doing it?

Karl
 
Karl,
Thanks for the answer.
Smith

Karl Seguin said:
heh..cpu cycles....those couple milliseconds will really come back to haunt
you....well, rest assured, when you do XXXXX.DataSource = DataSet/DataTable,
it automatically fetches the DefaultView from those (ie, you are always
binding to a DataView), so there is no performance penalty. Frankly, you
want things to be ordered but don't expect to spend any cpu cycles doing it?

Karl
 
Back
Top