title: ASP.NET GridView OnDataBound Sort in Code Behind
body: <p>I have a GridView where one of the columns/fields has checkboxes; the checkboxes are checked or unchecked, based on a sub-query from the code behind, while the container GridView is bound to a SqlDataSource. What I want to be able to do is that once the GridView is databound then make it sort by the state of checkboxes: All rows with checkboxes checked appear on the top of grid. Here is part of my GridView:</p>
  
  <pre><code>  &lt;ItemTemplate&gt;
       &lt;asp:CheckBox ID="ProductSelector" runat="server" Checked='&lt;%# ShowCheckMarks(DataBinder.Eval(Container.DataItem,"prodid").ToString()) %&gt;' /&gt;
      &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p>I am thinking that I can call the GridView's Ondatabound event and someone make it sort from there?
  Thanks.        </p>