I have a gridview and listview in my aspx pages which both display tables from my database, the first column field displayed is the ID field. I would like the ID in descending order by default when the aspx pages load up, so that the data displayed is from newest to oldest(I’m making a review website). I’m not sure how to do this, when the page loads up, it displays data in ascending order instead. Users are able to click the ID column and change the order, but that’s not what I want.
Any help on how to do this would be much appreciated!
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="DataSource">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
<asp:BoundField DataField="Date" HeaderText="Date"
SortExpression="Date" />
<asp:BoundField DataField="CPUModel" HeaderText="CPUModel"
SortExpression="CPUModel" />
<asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer"
SortExpression="Manufacturer" />
<asp:ImageField DataImageUrlField="Picture">
</asp:ImageField>
</Columns>
</asp:GridView>
Can’t you just order by ID through your SQL datasource queries?