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
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

751 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