views:

22

answers:

3

I have a datalist that shows information from a SQL table perfectly. Is there a way to show the information in reverse order?

Example:

Person1 Person2 Person3

Instead I would like:;

Person3 Person2 Person1

+1  A: 

see the DESCENDING option of SELECT

KevinDTimm
+2  A: 

Modify your SQL query to use ORDER BY <name> DESC.

David
That will work for showing the newest items first?
BioXhazard
Nevermind, I figured it out and it worked. Thanks.
BioXhazard
+1  A: 

If you don't want to do it server-side you could also use the Reverse extension method:

var items = myDataList.Items;
myDataList.Items = items.Reverse();

or more succinctly, but less obvious:

myDataList.Items = myDataList.Items.Reverse();
Randolpho
Is there a way to do this in VB?
BioXhazard
@BioXhazard: just replace `var` with `Dim` in the first example and remove the semicolons. (`;`) The second example will work exactly as is once you drop the semicolons.
Randolpho