ASP.NET: C# – How to re-arrange rows in a DataTable?

[c]

DataView view = dataTable.DefaultView; // dataTable has [Column 1], [Column 2], [Column X], [Column Y]
view.Sort = “[Column 1] DESC, [Column 2] DESC”;
DataTable newDataTable = view.ToTable(“new_tbl_name”, false, new string[] { “Column X”, “Column Y” }); // newDataTable has only [Column X], [Column Y]
[/c]

Be the first to comment

Leave a Reply

Your email address will not be published.


*