Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort items in datatable

Tags:

c#

I have a datatable with one column that contain names.I want to load combobox with datatable such that names should be in alphabetic order for eg:first name starts with a. second name starts with b.How can i sort data in datatable.Can anybody help?

like image 752
user42348 Avatar asked Feb 19 '10 05:02

user42348


1 Answers

Use a DataView:

DataTable dt; //comes from somewhere...
DataView dv = new DataView(dt)
dv.Sort = "Name ASC";
foreach(DataRowView drv in dv)
    //....
like image 156
Seva Alekseyev Avatar answered Oct 03 '22 08:10

Seva Alekseyev