NameSpace:  System.Data

We need to use DataView.Sort Property

Let us consider you already have a Datatable dt with some content in it and you want sort it in ascending order by the column Rollno

Then…

DataView dvt=new Dataview(dt);

dvt.sort=”RollNno ASC”;

//then again assign that view to datatable dt.

dt=dvt.ToTable();

Reference: https://msdn.microsoft.com/en-us/library/system.data.dataview.sort%28v=vs.110%29.aspx

Advertisements