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

    Domanda

  • Hi all,

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

    TY David

    • Spostato Bob Wu-MT martedì 3 aprile 2012 02:54 (From:Windows Forms Data Controls and Databinding)
    domenica 1 aprile 2012 14:23

Risposte

  • 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


    martedì 10 aprile 2012 03:27

Tutte le risposte

  • 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

    martedì 3 aprile 2012 02:53
  • 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

    martedì 3 aprile 2012 05:45
  • thanks for your welcome,

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

    Regards, David

    domenica 8 aprile 2012 08:23
  • 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


    martedì 10 aprile 2012 03:27
  • Thanks, that was useful
    martedì 10 aprile 2012 10:57