How to sort the data in Datatable

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between entity framework and ado.net?

534


What is ado oledb and odbc?

568


What are the data providers in ADO.NET framework?

654


What provider ado.net use by default? Explain the role of data provider in ado.net?

595


What are the advantages of oledb compared with other classes?

2381






Explain executenonquery?

631


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

612


What is meant by executenonquery?

589


What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?

606


What is ambient transaction?

567


What is the role of clr?

596


What is the default timeout specified for "sqlcommand.commandtimeout" property?

602


Name which operations can you not perform on an ado.net dataset?

546


What is the difference between OLEDB Provider and SqlClient?

589


What is ado asp?

587