title: How to add multiple SelectParameters to a SqlDataSource?
body: <p>I have been trying to add two SelectParameters to my SqlDataSource with no avail.</p>
  
  <p>Below is my code in the aspx page</p>
  
  <pre><code>&lt;table&gt;
          &lt;tr&gt;
              &lt;td colspan="2"&gt;&lt;strong&gt;Search By child&lt;/strong&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Case Number:
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="txtCaseNumber" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Last Name:
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="txtLastName" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;First Name:
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="txtFirstName" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="2"&gt;
                  &lt;asp:LinkButton ID="lnkSearchChild" runat="server"&gt;Search&lt;/asp:LinkButton&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  
  &lt;asp:GridView ID="childListGrid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" PageSize="20" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="child_recordId" HeaderText="Child ID" InsertVisible="False" ReadOnly="True" SortExpression="child_recordId" /&gt;
              &lt;asp:BoundField DataField="child_caseNumber" HeaderText="Case Number" SortExpression="child_caseNumber" /&gt;
              &lt;asp:BoundField DataField="child_LastName" HeaderText="Last Name" SortExpression="child_LastName" /&gt;
              &lt;asp:BoundField DataField="child_FirstName" HeaderText="First Name" SortExpression="child_FirstName" /&gt;
              &lt;asp:TemplateField HeaderText=" " InsertVisible="False"
                  SortExpression="child_recordId"&gt;
                  &lt;ItemTemplate&gt;
                      &amp;nbsp;&amp;nbsp;
                          &lt;asp:LinkButton ID="lnkViewForms" runat="server" CommandName="ViewForms" CommandArgument='&lt;%# Bind("child_recordId") %&gt;' OnClick="lnkViewForms_Click"&gt;View forms&lt;/asp:LinkButton&gt;
                      &amp;nbsp;&amp;nbsp;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
          &lt;FooterStyle BackColor="#CCCC99" ForeColor="Black" /&gt;
          &lt;HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" /&gt;
          &lt;PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" /&gt;
          &lt;SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" /&gt;
          &lt;SortedAscendingCellStyle BackColor="#F7F7F7" /&gt;
          &lt;SortedAscendingHeaderStyle BackColor="#4B4B4B" /&gt;
          &lt;SortedDescendingCellStyle BackColor="#E5E5E5" /&gt;
          &lt;SortedDescendingHeaderStyle BackColor="#242121" /&gt;
      &lt;/asp:GridView&gt;
  
  &lt;asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="&lt;%$ ConnectionStrings:eci_conn %&gt;" SelectCommand="SELECT ... FROM ... WHERE [child_LastName] LIKE @lname + '%' AND [child_FirstName] LIKE @fname + '%' ORDER BY [child_LastName]"&gt;
          &lt;SelectParameters&gt;
              &lt;asp:ControlParameter Name="lname" DbType="String" /&gt;
              &lt;asp:ControlParameter Name="fname" DbType="String" /&gt;
          &lt;/SelectParameters&gt;
      &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>And in my code behind I tried the following</p>
  
  <pre><code>    Dim lNameParam As New Parameter("@lname", DbType.String)
      Dim fNameParam As New Parameter("@fname", DbType.String)
      lNameParam.DefaultValue = txtLastName.Text.Trim()
      fNameParam.DefaultValue = txtFirstName.Text.Trim()
      SqlDataSource5.SelectParameters.Add(lNameParam)
      SqlDataSource5.SelectParameters.Add(fNameParam)
      childListGrid.DataSourceID = "SqlDataSource5"
  </code></pre>
  
  <p>and also this</p>
  
  <pre><code>SqlDataSource5.SelectParameters.Add("@lname", txtLastName.Text.Trim())
  SqlDataSource5.SelectParameters.Add("@fname", txtFirstName.Text.Trim())
  childListGrid.DataSourceID = "SqlDataSource5"
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>SqlDataSource5.SelectParameters("lname").DefaultValue = txtLastName.Text.Trim()
  SqlDataSource5.SelectParameters("fname").DefaultValue = txtFirstName.Text.Trim()
  childListGrid.DataSourceID = "SqlDataSource5"
  </code></pre>
  
  <p>Nothing seems to be working, what else can I try?</p>
  
  <p>thanks</p>