Can a datatable be sorted within itself?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hmakled
    New Member
    • Aug 2011
    • 1

    Can a datatable be sorted within itself?

    Hi,

    I would like to know if a datatable can be sorted and returned back to the calling procedure. I don't want to sort using datarows[] or dataviews. For example:

    Here is what I'm doing:

    DataRow[] rows = dt.Select("1 = 1", "Returnable_Cnt r"); // sort on "Returnable_Cnt r"
    for(int i = 0; i < rows.Length; i++)
    rows[i]["Line_Num"] = (i + 1).ToString().T rim();

    return dt;

    Now my problem is when the datatable "dt" returns its not sorted. Is there anyway i can get that sorted or write the sorted rows back to the datatable?

    Please help.

    thanks
  • NitinSawant
    Contributor
    • Oct 2007
    • 271

    #2
    Try this

    Code:
    dt.Select("","Returnable_Cntr ASC")

    Comment

    Working...