Solved

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

Posted on 2014-11-18
3
321 Views
Last Modified: 2014-11-19
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
Comment
Question by:cdlciddit
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 500 total points
ID: 40451834
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
 

Author Comment

by:cdlciddit
ID: 40452722
Thank you. One of those options worked.
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 40453014
I'm glad it helped you to fix weird issue.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now