How can I change the default sort direction when clicking a column in a GridView?
<p>How can I change the default sort direction when clicking a column in an ASP.NET GridView?</p>

<p>I would like it so that when a new column is clicked, it sorts in DESC order by default instead of ASC.</p>

<pre><code>
protected void OnGridViewSorting(object sender, GridViewSortEventArgs e)
    {
        DataTable dataTable = RoomsGrid.DataSource as DataTable;
        if (dataTable != null)
        {
            DataView dataView = new DataView(dataTable);
            dataView.Sort = e.SortExpression + " " +ConvertSortDirectionToSql(e.SortDirection);

            RoomsGrid.DataSource = dataView;
            RoomsGrid.DataBind();
        }
    }

private string ConvertSortDirectionToSql(SortDirection sortDirection)
{
    string newSortDirection = String.Empty;
    switch (sortDirection)
    {
        case SortDirection.Ascending: newSortDirection = "ASC"; break;
        case SortDirection.Descending: newSortDirection = "DESC"; break;
    }
    return newSortDirection;
}
</code></pre>

<p>Here's an example of how it behaves now:
<a href="http://www.venuefinder.com/venues/national_motorcycle_museum/V4204/meeting-rooms/" rel="nofollow">http://www.venuefinder.com/venues/national_motorcycle_museum/V4204/meeting-rooms/</a></p>
