Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Why do I get the error Exception Details: System.ArgumentException: A ControlID must be specified in ControlParameter ''. When it is specified

Hello. I'm trying to have 2 searches on one page.   When I use this code both searches work fine:

<%--<%@ Page Title="" Language="VB" MasterPageFile="~/Layout.master" AutoEventWireup="false" CodeFile="providerSearch.aspx.vb" Inherits="SchoolPsychology_tbi_providerSearch" %>--%>
<%@ Page Language="VB" MasterPageFile="~/SchoolPsychology/RPR.master" Title="Providers Search Page" CodeFile="~/SchoolPsychology/tbi/providerSearch.aspx.vb" Inherits="SchoolPsychology_tbi_providerSearch"%>
<%@ MasterType TypeName="CIDD.MasterPage" %>

<%@ Import Namespace="DbConduit.Db" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<%@ Register TagPrefix="ig" TagName="rprContacts" Src="~/SchoolPsychology/rprContacts_tbi.ascx" %>



<asp:Content ID="Content2" ContentPlaceHolderID="Content" Runat="Server">
    Search for Providers by County or Last Name<br />
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;&nbsp;
    <asp:Button ID="Button1" runat="server" Text="Search Providers by County" />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." EnableModelValidation="True" ForeColor="#333333" GridLines="None" AllowPaging="true">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="Last_name" HeaderText="Last Name" SortExpression="Last_name" />
            <asp:BoundField DataField="First_name" HeaderText="First Name" SortExpression="First_name" />
            <asp:BoundField DataField="County" HeaderText="County" SortExpression="County" />
            <asp:BoundField DataField="Employer" HeaderText="Employer" SortExpression="Employer" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TBIConnectionString %>" FilterExpression="[County] LIKE '%{0}%'" SelectCommand="SELECT [Last name] AS Last_name, [First name] AS First_name, [County], [Employer/School System] AS Employer, [Email], [Phone] FROM [Providers]">
        <FilterParameters>
            <asp:ControlParameter ControlID="TextBox1" Name="County" PropertyName="Text" Type="String" DefaultValue="1" />
        </FilterParameters>
    </asp:SqlDataSource>
    <br />
    <br />
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
&nbsp;&nbsp;
    <asp:Button ID="Button2" runat="server" Text="Search Providers by Last Name" />
    <br />
     <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource2" EmptyDataText="There are no data records to display." EnableModelValidation="True" ForeColor="#333333" GridLines="None">
         <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
         <Columns>
             <asp:BoundField DataField="Last_name" HeaderText="Last_name" SortExpression="Last_name" />
             <asp:BoundField DataField="First_name" HeaderText="First_name" SortExpression="First_name" />
             <asp:BoundField DataField="County" HeaderText="County" SortExpression="County" />
             <asp:BoundField DataField="column1" HeaderText="column1" SortExpression="column1" />
             <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
             <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
         </Columns>
         <EditRowStyle BackColor="#999999" />
         <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
         <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
         <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TBIConnectionString %>" SelectCommand="SELECT [Last name] AS Last_name, [First name] AS First_name, [County], [Employer/School System] AS column1, [Email], [Phone] FROM [Providers] WHERE ([Last name] LIKE '%' + @Last_name + '%')">
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox2" Name="Last_name" PropertyName="Text" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
    <br />
</asp:Content>

Open in new window


But when I try to change the 2nd datasource to include the filter expression attribute and the <FilterParameters> and the <asp:ControlParameter> Then I get the error: Exception Details: System.ArgumentException: A ControlID must be specified in ControlParameter ''.
I'm sure I specify the ID here is the code where I specify the ID:

<FilterParameters>
            <asp:ControlParameter ControlID="TextBox2" Name="Last_name" PropertyName="Text" Type="String" DefaultValue="1" />
        </FilterParameters>

Open in new window


This is all the code on that page that gives me the error after I change the datasource to include the
FilterExpression="[County] LIKE '%{0}%'"

Open in new window

and I add this
<FilterParameters>
            <asp:ControlParameter ControlID="TextBox2" Name="Last_name" PropertyName="Text" Type="String" DefaultValue="1" />
        </FilterParameters>

Open in new window


Here is all the code that doesn't work
<%--<%@ Page Title="" Language="VB" MasterPageFile="~/Layout.master" AutoEventWireup="false" CodeFile="providerSearch.aspx.vb" Inherits="SchoolPsychology_tbi_providerSearch" %>--%>
<%@ Page Language="VB" MasterPageFile="~/SchoolPsychology/RPR.master" Title="Providers Search Page" CodeFile="~/SchoolPsychology/tbi/providerSearch.aspx.vb" Inherits="SchoolPsychology_tbi_providerSearch"%>
<%@ MasterType TypeName="CIDD.MasterPage" %>

<%@ Import Namespace="DbConduit.Db" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<%@ Register TagPrefix="ig" TagName="rprContacts" Src="~/SchoolPsychology/rprContacts_tbi.ascx" %>



<asp:Content ID="Content2" ContentPlaceHolderID="Content" Runat="Server">
    Search for Providers by County or Last Name<br />
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;&nbsp;
    <asp:Button ID="Button1" runat="server" Text="Search Providers by County" />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." EnableModelValidation="True" ForeColor="#333333" GridLines="None" AllowPaging="true">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="Last_name" HeaderText="Last Name" SortExpression="Last_name" />
            <asp:BoundField DataField="First_name" HeaderText="First Name" SortExpression="First_name" />
            <asp:BoundField DataField="County" HeaderText="County" SortExpression="County" />
            <asp:BoundField DataField="Employer" HeaderText="Employer" SortExpression="Employer" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TBIConnectionString %>" FilterExpression="[County] LIKE '%{0}%'" SelectCommand="SELECT [Last name] AS Last_name, [First name] AS First_name, [County], [Employer/School System] AS Employer, [Email], [Phone] FROM [Providers]">
        <FilterParameters>
            <asp:ControlParameter ControlID="TextBox1" Name="County" PropertyName="Text" Type="String" DefaultValue="1" />
        </FilterParameters>
    </asp:SqlDataSource>
    <br />
    <br />
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
&nbsp;&nbsp;
    <asp:Button ID="Button2" runat="server" Text="Search Providers by Last Name" />
    <br />
     <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource2" EmptyDataText="There are no data records to display." EnableModelValidation="True" ForeColor="#333333" GridLines="None">
         <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
         <Columns>
             <asp:BoundField DataField="Last_name" HeaderText="Last_name" SortExpression="Last_name" />
             <asp:BoundField DataField="First_name" HeaderText="First_name" SortExpression="First_name" />
             <asp:BoundField DataField="County" HeaderText="County" SortExpression="County" />
             <asp:BoundField DataField="column1" HeaderText="column1" SortExpression="column1" />
             <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
             <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
         </Columns>
         <EditRowStyle BackColor="#999999" />
         <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
         <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
         <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
         <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TBIConnectionString %>"  FilterExpression="[County] LIKE '%{0}%'"  SelectCommand="SELECT [Last name] AS Last_name, [First name] AS First_name, [County], [Employer/School System] AS column1, [Email], [Phone] FROM [Providers]">
        <FilterParameters>
            <asp:ControlParameter ControlID="TextBox2" Name="Last_name" PropertyName="Text" Type="String" DefaultValue="1" />
        </FilterParameters>
    </asp:SqlDataSource>
    <br />
    <br />
</asp:Content>

Open in new window

0
cdlciddit
Asked:
cdlciddit
  • 2
1 Solution
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
Well! I don't think there is any sort of issue in code itself. I had examined it carefully (to my best).

So now what I suspect that your website (which might be hosted on server) is having some old compiled binaries with not updated.

As a solution, I would recommend you to -
1. Clean all sort of temporary files from E:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
2. Close Visual Studio and open project again. Rebuild same.
3. Now test it.

Share your results.
0
 
cdlcidditAuthor Commented:
Thank you. One of those options worked.
0
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
I'm glad it helped you to fix weird issue.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now