Sorting in a datagrid

ShadoWbg

New Member
Th following codes create a directory listing bound to a datagrid. It gives me a list of files in the filename's alphabetical order. What I want to do is show, on load, the list by their creationdate starting from the latest to the oldest. How can I do this?<BR><BR><BR><asp:datagrid id="DataGrid1" runat="server" Width="500px" AllowSorting="True" HorizontalAlign="Center" CellPadding="1" BorderWidth="1px" CellSpacing="1" BorderColor="Black" AutoGenerateColumns="False"><BR> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="White" BackColor="#003399"></HeaderStyle><BR> <Columns><BR> <asp:HyperLinkColumn DataNavigateUrlField="Name" DataNavigateUrlFormatString="SFTNews{0}" DataTextField="Name" SortExpression="Name" HeaderText="File Name"><BR> <ItemStyle HorizontalAlign="Center"></ItemStyle><BR> </asp:HyperLinkColumn><BR> <asp:BoundColumn DataField="CreationTime" SortExpression="creationdate" HeaderText="Date Created"><BR> <HeaderStyle HorizontalAlign="Center"></HeaderStyle><BR> <ItemStyle HorizontalAlign="Center"></ItemStyle><BR> </asp:BoundColumn><BR> </Columns><BR> </asp:datagrid><BR><BR>--codebehind codes<BR>Dim dir As New DirectoryInfo(Server.MapPath("SFTNews")) If dir.Exists() Then<BR> DataGrid1.DataSource = dir.GetFiles()<BR> DataGrid1.DataBind()<BR>End IfCan I sort the filenames returned by Direcory.getFiles() by creationdate?The GetFiles() returns an array, no? Can't you use the Array class's Sort method? If not, you'll have to roll your own... hth
 
Back
Top