Order by Clause....

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
 
K

Karl Seguin

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

Karl
 
S

Smith John

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
 
S

Smith John

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
 
K

Karl Seguin

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
 
J

John Smith

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top