How to sort the data in Datatable

Answers were Sorted based on User's Feedback



How to sort the data in Datatable..

Answer / kamalakannan.a

I think the above answer is correct.Another one method is

DataTable dt=new DataTable();
DataRow[] dr=dt.Select("Filter Expression","Sort
expression");

Here Sort expression is , for eg.Address is one of the
field in dt.

Then DataRow[] dr=dt.Select("","Address ASC");

But in this method is have the Datarow array.So you can use
another one method,I explain below.

DataView dv=new DataView(Datatable,Filter Exp,Sort
Exp,Dataviewrowstate)


Eg is

DataView dv=new DataView(dt,"","Address
ASC,DataViewVowState.CurrentRows);


Here we can copy this Dataview to datatable or use this
same dataview instead of datatable.

Kamal....

Is This Answer Correct ?    28 Yes 3 No

How to sort the data in Datatable..

Answer / narayansahu

pass the datatable in dataview object and call the sort
method on dataview
dataview dv=new dataview(dt)
dv.sort
that's it

Is This Answer Correct ?    17 Yes 17 No

Post New Answer

More ADO.NET Interview Questions

How to add a javaScript function in a datagrid?

0 Answers   C DAC, CDAC,


Command objects uses, purposes and their methods.

0 Answers  


What is sqldatareader in ado.net?

0 Answers  


How can you implement sub data grid in a master datagrid?

1 Answers  


Explain the two fundamental objects in ado.net?

0 Answers  






What is the default Timeout for SqlCommand.CommandTimeout property?

0 Answers  


What is difference between ado and other data object?

0 Answers  


can we execute trigger normally at the desired time?

3 Answers   Microsoft,


Which parameter of ConnectionString is used to specify the name of the database?

0 Answers  


What are the advantages and disadvantages of using datalist?

0 Answers  


What is the difference between Response.Expires and Reponse.ExpiresAbsolute?

0 Answers  


Which is better entity framework or ado.net?

0 Answers  


Categories