title: Code to create Sorting for a GridView in ASP.net in Code Behind?
body: <p>This is my code code for the Page_Load Event</p>
  
  <pre><code>            OdbcConnection myConnection;
              DataSet dataSet = new DataSet();
              OdbcDataAdapter adapter;
  
              //making my connection
              myConnection = new OdbcConnection(ConfigurationManager.ConnectionStrings  ["ODBC_ConnectionString"].ConnectionString);
  
              adapter = new OdbcDataAdapter("SELECT * from Company", myConnection);
  
              adapter.Fill(dataSet, "MyData");
  
              GridView1.DataSource = dataSet;
              Session["DataSource"] = dataSet;
              GridView1.DataBind();
  </code></pre>
  
  <p>This is my code for the PageIndexChanging event and it all works fine.</p>
  
  <pre><code>           DataSet ds = new DataSet();
  
              if (Session["DataSource"] != null)
                  ds = ((DataSet)Session["DataSource"]);
  
              GridView1.DataSource = ds;
              GridView1.PageIndex = e.NewPageIndex;
              this.GridView1.DataBind();
  </code></pre>
  
  <p>Now what code do i need to create the Sorting event?</p>
  
  <pre><code>protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
      {
          ?????????????????????????
      }
  </code></pre>
  
  <p>Etienne</p>