Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Sorting a collection within a datatable

Sorting a collection within a datatable

Scheduled Pinned Locked Moved ASP.NET
algorithmsarchitecturehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    viktor9990
    wrote on last edited by
    #1

    I'm trying to sort data (by startdate and descendant) in a collection object (CollectionActivities.Sort("StartDate", 0);) and print these data within a datable during run time. Everything is o.k. except the sorting order which is not working. Notice that the same collection(CollectionActivities) is sorting well when It is returned to the caller and bound to a datagrid. My solution require that I use the first way. Any help is highly appreciated. Here is my code: //Enumeration to define the sort orders protected enum enuSortOrder:int { soAscending = 0, soDescending = 1 } private void Page_Load(object sender, System.EventArgs e) { ListScopesWithActivities() } public void ListScopesWithActivities() { ListItemCollectionByScope CollectionScopes = new ListItemCollectionByScope(); ListItemCollectionByScope CollectionGoalDescriptions = new ListItemCollectionByScope(); ListItemCollectionByScope CollectionActivities = new ListItemCollectionByScope(); string colRedImage = ""; string colGreenImage = ""; // Define the child controls Table _table = new Table(); TableCell _tableCell; TableRow _tableRow; _table.ID = "InfoTable"; _table.CellPadding = 0; _table.CellSpacing = 0; _table.BorderColor = Color.Tan; _table.BorderWidth = Unit.Pixel(0); _table.BorderStyle = BorderStyle.Solid; _table.GridLines = GridLines.Both; //Get collection of scopes PageDataCollection pdc = Global.EPDataFactory.GetChildren(MogulEPiServer.GetPage(CurrentPage.PageLink.ID).PageLink); if(pdc.Count > 0) { foreach(PageData pd in pdc) { ListActivityItemByScope liScope = new ListActivityItemByScope(); //Get the property values for Scope from PageName string strScope = MogulEPiServer.PageName(pd.PageLink.ID); liScope.Scope = strScope; CollectionScopes.Add(liScope); //Create the row for Scope _tableRow = new TableRow(); _tableCell = new TableCell(); _tableCell.ColumnSpan = 5; _tableCell.Text = "
    Område: " + liScope.Scope; _tableRow.Cells.Add(_tableCell); _table.Rows.Add(_tableRow); //Get collection of GoalsDescriptions PageDataCollection pdc2 = Global.EPDataFactory.GetChildren(MogulEPiServer.GetPage(pd.PageLink.ID).PageLink); foreach(PageData pd2 in pdc2) { //Get property values for GoalDescription if(MogulEPiServer.GetPage(pd2.PageLink.ID).Property["GoalDescription"].Value !

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups