how to sort single row from datatable in descending order in asp.net?
for example,
i have one row like
40,45,10,15
after
45,40,15,10
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Oct 8, 2013, 9:33 AM
hi,
try following code
DataTable dt = new DataTable();
dt.Columns.Add("mydata");
dt.Rows.Add("40,45,10,15");
foreach (DataRow drow in dt.Rows)
{
drow[0] = string.Join(",", Convert.ToString(drow[0]).Split(new char[] { ',' }).OrderByDescending(f1=>Convert.ToInt32(f1)));
drow.EndEdit();
dt.AcceptChanges();
}
hope this will help you.
Puneet GuptaPosted Oct 8, 2013, 8:07 AM
http://www.c-sharpcorner.com/blogs/8973/sorting-data-in-c-sharp-datatable.aspx
Thanks,
Puneet Gupta