title: access selectcommand using codebehind
body: <p>How can I change my selecommand, and keep it through the remainder of the page (when using pagination, sorting)?</p>
  
  <p>I have a page of checkboxes:</p>
  
  <pre><code>&lt;input type="checkbox" name="checkbox_1" /&gt;
  &lt;input type="checkbox" name="checkbox_2" /&gt;
  &lt;input type="checkbox" name="checkbox_3" /&gt;
  &lt;asp:Button runat="server" Id="CustomButton" text="Create Report" PostBackUrl="report.aspx?"/&gt;
  </code></pre>
  
  <p>Then on report.aspx I want to generate a standard listview based on the selections in the checkbox.  </p>
  
  <pre><code> &lt;asp:ListView runat="server" ID="ReportListView" DataSourceID="ReportListViewSDS"&gt;
    &lt;LayoutTemplate runat="server"&gt;
         ...&lt;asp:PlaceHolder runat="server" ID="itemPlaceHolder" /&gt;...
    &lt;/LayoutTemplate&gt;
   &lt;ItemTemplate&gt;
       ...
   &lt;/ItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>I want to be able to sort and paginate that listview.  This is an idea of what i want in the code behind:</p>
  
  <pre><code>Protected Sub ReportListView_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
  
       ' What's the correct way to reference the listview?  
       ' When I use the below code i get "ReportListView is not declared...."
  
       ' ReportListView.SqlCommand = "SELECT " &amp; checkbox1 &amp; ", " &amp; checkbox2 &amp; " WHERE..."
  
  End Sub
  </code></pre>
  
  <p>I'm not sure if I'm even going in the right direction with this, any help is appreciated.  Will the changes i make to the sql command in the PreRender function hold when I have applied pagination or sorting to the listview?</p>