Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic datatable take Reverse order in asp.net

Tags:

c#

asp.net

In my web application, I have created

 DataTable dt= new DataTable();
 dt.Columns.Add("Month");

and made fill the column name "Month" with date as

Month(Column name)
oct-2014   
July-2016   
Aug-2016

and made fill my dynamic table

Now, i want this dynamic table data to be Reverse order

for eg:

    Month(Column name)
      Aug-2016
      July-2016        
      oct-2014

like this i need to display dynamic data table is first row is last and last row is first.

Thank you.


1 Answers

Try this.

  DataTable reversedDt = dt.Clone();
  for (var row = dt.Rows.Count - 1; row >= 0; row--)
         reversedDt .ImportRow(dt.Rows[row]);
like image 197
Vicky_Burnwal Avatar answered Oct 18 '25 06:10

Vicky_Burnwal