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
317 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

16 Experts available now in Live!

Get 1:1 Help Now