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

Explain what is datagrid with an example?

0 Answers   C DAC, CDAC,


What are the data providers in ADO.NET framework?

0 Answers  


ADO and ADO.NET differences ?

2 Answers   Microsoft,


How will you fill the gridview by using datatable object at runtime?

0 Answers  


differance between ADO vs ADO.Net?

0 Answers   MCN Solutions,






How to bind the controls(best practice) comboboxes to the data in the dataset?

0 Answers  


What do you mean by performing asynchronous operation using command object?

0 Answers  


What are the different methods by which we can populate a dataset?

0 Answers  


Can a DataReader be used as a DataSource for a GridView. If it is so how will you handle paging.

3 Answers   Directi,


Sequence to connect and retrieve data from database useig dataset ?

6 Answers   MMTS,


What are the main differences between classic ado and ado.net?

0 Answers  


What are the types of databinding?

0 Answers  


Categories