Michel jeams
Michel jeams

Reputation: 103

Sorting on Column of datatable as alphabetically..or filter column

I want to sort all the data of DataTable, I want sort on Column2 as alphabetically.

DataView dv = new DataView(DT);
dv.Sort = "Column2 ASC";
DT.DefaultView.Sort = "Column2 ASC";

Upvotes: 1

Views: 5655

Answers (1)

Gintas K
Gintas K

Reputation: 1478

DataView dv = yourDataTable.DefaultView;
dv.Sort = "Column2";                
yourDataTable = dv.ToTable();

You don't need to add ASC, it's a default, unless you want DESC :) This code worked for me :)

Upvotes: 1

Related Questions