title: Insert and Search Fields vb.net\asp.net web form to mssql
body: <p>I've created a page that spits out data from a table. I've gotten the update and delete functionality, but I'm having trouble figuring out how to search and add values. I threw in a few text boxes to mess around with, but I don't know how to make them into controls. I'd like to be able to search the data, as well as enter new data. How do I make these text boxes into search controls for the grid? Also how do I use text boxes or drop down boxes to insert new values into the table? </p>
  
  <p>Here is what I have so far: </p>
  
  <pre><code>    &lt;%@ Page Title="Bank Statements" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BankStatements.aspx.vb" Inherits="Compliance.BankStatements" %&gt;
  
  &lt;script runat="server"&gt;
  
      Protected Sub Page_Load(sender As Object, e As EventArgs)
  
      End Sub
  &lt;/script&gt;
  
  
  &lt;asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"&gt;
      &lt;hgroup class="title"&gt;
          &lt;h1&gt;&lt;%: Title %&gt;.&lt;/h1&gt;
          &lt;h2&gt;Enter View and Edit Bank Statments Here&lt;br /&gt;
          &lt;/h2&gt;
      &lt;/hgroup&gt;
  
  
  
      &lt;br /&gt;
  
      Franchise ID:       
      &lt;asp:TextBox ID="TextBox1" runat="server" Width="95px"&gt;&lt;/asp:TextBox&gt;
  &amp;nbsp; Year:&amp;nbsp;
      &lt;asp:TextBox ID="TextBox2" runat="server" Width="56px"&gt;&lt;/asp:TextBox&gt;
  &amp;nbsp; Month:&amp;nbsp;
      &lt;asp:TextBox ID="TextBox3" runat="server" Width="65px"&gt;&lt;/asp:TextBox&gt;
  &amp;nbsp;   
  
  &amp;nbsp;&lt;asp:GridView 
              ID="GridView1" 
              runat="server" 
              AllowSorting="True" 
              AutoGenerateColumns="False" 
              CellPadding="4" 
              DataSourceID="SqlDataSource1" 
              EmptyDataText="There are no data records to display." 
              ForeColor="#333333" 
              GridLines="None" 
              AutoGenerateDeleteButton="True" 
              AutoGenerateEditButton="True" 
              EnableSortingAndPagingCallbacks="True" 
              AllowPaging="True"
      &gt;
  
      &lt;AlternatingRowStyle BackColor="White" /&gt;
      &lt;Columns&gt;
  
          &lt;asp:BoundField DataField="FranchiseID" HeaderText="FranchiseID" SortExpression="FranchiseID" /&gt;
          &lt;asp:BoundField DataField="Year" HeaderText="Year" SortExpression="Year" /&gt;
          &lt;asp:BoundField DataField="Month" HeaderText="Month" SortExpression="Month" /&gt;
          &lt;asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" /&gt;
          &lt;asp:BoundField DataField="DatePosted" HeaderText="DatePosted" SortExpression="DatePosted" /&gt;    
  
      &lt;/Columns&gt;
      &lt;EditRowStyle BackColor="#7C6F57" /&gt;    
      &lt;FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt;
      &lt;HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt;
      &lt;PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /&gt;
      &lt;RowStyle BackColor="#E3EAEB" /&gt;
      &lt;SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /&gt;
      &lt;SortedAscendingCellStyle BackColor="#F8FAFA" /&gt;
      &lt;SortedAscendingHeaderStyle BackColor="#246B61" /&gt;
      &lt;SortedDescendingCellStyle BackColor="#D4DFE1" /&gt;
      &lt;SortedDescendingHeaderStyle BackColor="#15524A" /&gt;
  &lt;/asp:GridView&gt;
  &lt;hgroup&gt;
  &lt;/hgroup&gt;
  &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ComplianceConnectionString1 %&gt;" 
      SelectCommand=
                      "SELECT FranchiseID, Year, Month, Amount, DatePosted, id FROM BankStmts  ORDER BY DatePosted DESC"
      DeleteCommand=
                      "DELETE 
                      FROM [BankStmts] 
                      WHERE id = @id"
      UpdateCommand=
                      "UPDATE [BankStmts] 
                      SET FranchiseID = @FranchiseID, Year = @Year, Month = @Month, Amount = @Amount, DatePosted = @DatePosted 
                      WHERE id = @id"
      InsertCommand=
                      "Insert INTO [BankStmts] FranchiseID, Year, Month, Amount, DatePosted 
                      VALUES @FranchiseID, @Year, @Month, @Amount, @DatePosted"
  &gt;
  
      &lt;DeleteParameters&gt;
          &lt;asp:Parameter Name="id" /&gt;
      &lt;/DeleteParameters&gt;
      &lt;InsertParameters&gt;
          &lt;asp:Parameter Name="FranchiseID" /&gt;
          &lt;asp:Parameter Name="Year" /&gt;
          &lt;asp:Parameter Name="Month" /&gt;
          &lt;asp:Parameter Name="Amount" /&gt;
          &lt;asp:Parameter Name="DatePosted" /&gt;
      &lt;/InsertParameters&gt;
  
      &lt;UpdateParameters&gt;
          &lt;asp:Parameter Name="FranchiseID" /&gt;
          &lt;asp:Parameter Name="Year" /&gt;
          &lt;asp:Parameter Name="Month" /&gt;
          &lt;asp:Parameter Name="Amount" /&gt;
          &lt;asp:Parameter Name="DatePosted" /&gt;
          &lt;asp:Parameter Name="id" /&gt;
      &lt;/UpdateParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  
  
  
  &lt;/asp:Content&gt;
  </code></pre>