datatable sort and modification RRS feed

  • Question

  • Hi all,


    i am having a hard time sorting the columns of a datatable in a reverse order, thats all i want to do, and from some reason it keeps complaining about trying to copy a column that belongs to another table, another question is how do i turn a table 90 degrees to the right so instead of:

    name     number

    alon       1234


    i will get:

    name          alon

    number     1234


    i am sure theres no automatic way but it will be nice to get some advice, important to mention that i dont have multiple rows in this last table, only the row of the column names and one row of data.


    tnx alot, alon

    Friday, August 10, 2007 9:52 AM

All replies

  • try this


    Code Snippet

    if (sortExpression != null && sortExpression.Length > 0) 
        table.DefaultView.Sort = sortExpression + " " + sortOrder;



    Friday, August 10, 2007 10:03 AM
  • i've read about this sorting function and it doesnt seem to be able to sort the datatable's columns, all i want is to reverse the order of the columns, this function lets me sort all the data by a specific column.

    Friday, August 10, 2007 4:17 PM
  • Have a look at the SetOrdinal method that exists on DataColumn...
    Friday, August 10, 2007 9:50 PM