title: GridView sorting: SortDirection always Ascending
body: <p>I have a gridview and I need to sort its elements when the user clicks on the header.<br>
  Its datasource is a List object.</p>
  
  <p>The aspx is defined this way :</p>
  
  <pre><code>&lt;asp:GridView ID="grdHeader" AllowSorting="true" AllowPaging="false" 
      AutoGenerateColumns="false" Width="780" runat="server"  OnSorting="grdHeader_OnSorting" EnableViewState="true"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="Entitycode" HeaderText="Entity" SortExpression="Entitycode" /&gt;
          &lt;asp:BoundField DataField="Statusname" HeaderText="Status" SortExpression="Statusname" /&gt;
          &lt;asp:BoundField DataField="Username" HeaderText="User" SortExpression="Username" /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>The code behind is defined this way :<br>
  First load :</p>
  
  <pre><code>protected void btnSearch_Click(object sender, EventArgs e)
  {
      List&lt;V_ReportPeriodStatusEntity&gt; items = GetPeriodStatusesForScreenSelection();
      this.grdHeader.DataSource = items;
      this.grdHeader.DataBind();
  }
  </code></pre>
  
  <p>when the user clicks on headers :</p>
  
  <pre><code>protected void grdHeader_OnSorting(object sender, GridViewSortEventArgs e)
  {
      List&lt;V_ReportPeriodStatusEntity&gt; items = GetPeriodStatusesForScreenSelection();
      items.Sort(new Helpers.GenericComparer&lt;V_ReportPeriodStatusEntity&gt;(e.SortExpression, e.SortDirection));
      grdHeader.DataSource = items;
      grdHeader.DataBind();
  }
  </code></pre>
  
  <p>My problem is that e.SortDirection is always set to Ascending.<br>
  I have webpage with a similar code and it works well, e.SortDirection alternates between Ascending and Descending.</p>
  
  <p>What did I do wrong ?</p>