How to sort a DataRepeater by a field's value?
-
domenica 1 aprile 2012 14:23
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-MTMicrosoft Contingent Staff martedì 3 aprile 2012 02:54 (From:Windows Forms Data Controls and Databinding)
Tutte le risposte
-
martedì 3 aprile 2012 02:53Hi 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 05:45Moderatore
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
-
domenica 8 aprile 2012 08:23
thanks for your welcome,
May you give me a clue about where to insert such SQL code?
Regards, David
-
martedì 10 aprile 2012 03:27Moderatore
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
- Modificato Mark Liu-lxfModerator martedì 10 aprile 2012 03:27
- Contrassegnato come risposta David De martedì 10 aprile 2012 10:57
-
martedì 10 aprile 2012 10:57Thanks, that was useful

