How to sort a DataRepeater by a field's value?

Locked How to sort a DataRepeater by a field's value?

  • Sunday, April 01, 2012 2:23 PM
     
     

    Hi all,

    I need to sort (in ascendent/descendent order) a DataRepeater by a field (say PostDate). How can do this?

    TY David

All Replies

  • Tuesday, April 03, 2012 2:53 AM
     
     
    Hi David,
    Since Datarepeater control is in Microsoft.VisualBasic.PowerPacks namespace, I will help you move this thread to Visual Basic Power Packs forum. There are more related experts could help you about this.
    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

  • Tuesday, April 03, 2012 5:45 AM
    Moderator
     
     

    Hi David,

    Welcome to the MSDN forum.

    As far as I knew, the DataRepeater Class doesn’t contain the sort method. If you want to sort the items showed in the DataRepeater, I will suggest you to sort the data using SQL query (Order by). In this way, all the records will be in order when banding the data to the DataRepeater Control.

    Hope this helps.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

  • Sunday, April 08, 2012 8:23 AM
     
     

    thanks for your welcome,

    May you give me a clue about where to insert such SQL code?

    Regards, David

  • Tuesday, April 10, 2012 3:27 AM
    Moderator
     
     Answered

    Hi David,

    I have no idea about the way you used the DataRepeater. I assume you use the DataRepeater to show the bound data (How to: Display Bound Data in a DataRepeater Control (Visual Studio)).

    Please change the SQL query in following steps:

    1. Double click the Dataset file in Solution Explorer windows, you will find the datatable.

    2. Select the table you want to display, and edit the commandText (add the ORDER BY …) in the Fill query.  

    In this way, the data in DataRepeater will be sorted by the item you want.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us


  • Tuesday, April 10, 2012 10:57 AM
     
     
    Thanks, that was useful