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

    Pergunta

  • Hi all,

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

    TY David

    • Movido Bob Wu-MT terça-feira, 3 de abril de 2012 02:54 (From:Windows Forms Data Controls and Databinding)
    domingo, 1 de abril de 2012 14:23

Respostas

  • 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


    terça-feira, 10 de abril de 2012 03:27
    Moderador

Todas as Respostas

  • 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

    terça-feira, 3 de abril de 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

    terça-feira, 3 de abril de 2012 05:45
    Moderador
  • thanks for your welcome,

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

    Regards, David

    domingo, 8 de abril de 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


    terça-feira, 10 de abril de 2012 03:27
    Moderador
  • Thanks, that was useful
    terça-feira, 10 de abril de 2012 10:57