title: How can I use a WHERE clause in GridView control?
body: <p>I want to create a where clause so that I can get the values from the database to the gridview with some particular id which I have stored in ViewState on page load. Where clause is marked in stars in the code </p>
  
  <pre><code>&lt;asp:GridView ID="gvView" runat="server" AutoGenerateColumns="false" DataKeyNames="ID"
                  DataSourceID="SqlDataSource" AllowPaging="true" PageSize="50" Width="100%"
                  EmptyDataText="--- No records yet. ---" PagerStyle-HorizontalAlign="Center" PagerSettings-PageButtonCount="5"
                  EmptyDataRowStyle-ForeColor="#888581" EmptyDataRowStyle-Font-Size="14px" EmptyDataRowStyle-Height="30px"
                  EmptyDataRowStyle-Font-Italic="true" AlternatingRowStyle-BackColor="#E2E2E2"
                  PagerStyle-CssClass="pager"&gt;
                  &lt;Columns&gt;
                      &lt;asp:TemplateField HeaderText="Select"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:CheckBox ID="RowSelector" runat="server" /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" Visible="false" /&gt;
                      &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /&gt;
  
  
                  &lt;/Columns&gt;
              &lt;/asp:GridView&gt;
              &lt;asp:SqlDataSource ID="SqlDataSource" runat="server" 
                  ProviderName="System.Data.SqlClient" ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;"
                  SelectCommand="SELECT ID, Title FROM Table **WHERE AnotherID=@AnotherID** ORDER BY ID"&gt;
              &lt;/asp:SqlDataSource&gt;
  </code></pre>