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
Solved

Error with the command

Posted on 2013-01-17
6
431 Views
Last Modified: 2013-01-18
Hi,
Why do I get this?
Could not find control 'int_list' in ControlParameter 'desc'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Could not find control 'int_list' in ControlParameter 'desc'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[InvalidOperationException: Could not find control 'int_list' in ControlParameter 'desc'.]
   System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +3226150
   System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +152
   System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +113
   System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +47
   System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +444
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +214
   System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +3696829
   System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +678
   System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +148
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +84
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

to this Sqldatasource
    ...
    <asp:SqlDataSource
    ID="ds_user_int" Runat="server"
    ConnectionString="<%$ ConnectionStrings:Mssqlconn2 %>"
    ProviderName="System.Data.SqlClient"

    SelectCommand="select int_desc,change_date from tab2 order by 1"
    Insertcommand="insert into tab2 (user_id,int_desc,change_date) values (cast(@userid as decimal(10,0)),@desc,@dt)" >
          <insertparameters>
              <asp:ControlParameter ControlID="lb_userid" Name="userid" PropertyName="Text" />
              <asp:ControlParameter ControlID="int_list" Name="desc" PropertyName="Text" />
              <asp:ControlParameter ControlID="change_date" Name="dt" PropertyName="Text" />
          </insertparameters>
    </asp:SqlDataSource>
    ...
   
while int_list is
   <asp:DropDownList ID="int_list"
        width="330px"
        DataSourceID="ds_int"
        runat="server"
        DataTextField="int_desc"
        DataValueField="int_desc" >
    </asp:DropDownList>
0
Comment
Question by:HuaMinChen
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 38791962
Change the PropertyName for the desc ControlParameter to SelectedValue :

  <asp:ControlParameter ControlID="int_list" Name="desc" PropertyName="SelectedValue" />
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38791980
Sorry I still get this
Could not find control 'int_list' in ControlParameter 'desc'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Could not find control 'int_list' in ControlParameter 'desc'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[InvalidOperationException: Could not find control 'int_list' in ControlParameter 'desc'.]
   System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +3226150
   System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +152
   System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +113
   System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +47
   System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +444
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +214
   System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +3696829
   System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +678
   System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +148
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +84
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

after I've changed it to be
    <asp:DropDownList ID="int_list"
        width="330px"
        DataSourceID="ds_int"
        runat="server"
        name="desc"
        DataTextField="int_desc"
        DataValueField="int_desc"
        PropertyName="SelectedValue" >
    </asp:DropDownList>
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 38791998
Is the int_list control contained within another control ?
Can you comment out the controlparameter and then view the source of the page and see what id the dropdownlist control has been given it may be something like :

myContainingControl$int_list
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 29

Expert Comment

by:Paul Jackson
ID: 38792007
Just read your previous post again, the propertyname attribute should be on the controlparameter control not the dropdownlist control, I would also remove name=desc from the dropdownlist control as it might be confusing the compiler :

  <asp:ControlParameter ControlID="int_list" Name="desc" PropertyName="Text" />

    <asp:DropDownList ID="int_list"
        width="330px"
        DataSourceID="ds_int"
        runat="server"
        DataTextField="int_desc"
        DataValueField="int_desc"
    </asp:DropDownList
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38792028
Many thanks. I am getting the same problem with these full codes of the relevant part. Please advise.
    <asp:FormView ID="int_fv" runat="server"
    DefaultMode="Insert"
    AutoGenerateColumns="false"
    BackColor="gray"
    AllowSorting="True"
    Title="Test"
    datasourceid="ds_user_int" >
    <InsertItemTemplate>
    <asp:DropDownList ID="int_list"
        width="330px"
        DataSourceID="ds_int"
        runat="server"
        BackColor="gray"
        DataTextField="int_desc"
        DataValueField="int_desc" >
    </asp:DropDownList>
    <asp:Textbox id="change_date" Text='<%# Bind("change_date") %>' runat="server" />
    <br />
    <asp:LinkButton ID="LinkButton6" runat="server" CommandName="insert">Insert</asp:LinkButton>
    &nbsp;<asp:LinkButton ID="LinkButton7" runat="server" CommandName="cancel">Cancel</asp:LinkButton>
    </InsertItemTemplate>
    <ItemTemplate>
        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="new">New</asp:LinkButton>
        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CommandName="delete">Delete</asp:LinkButton>
        &nbsp;<asp:LinkButton ID="LinkButton3" runat="server" CommandName="edit">Edit</asp:LinkButton>
    </ItemTemplate>
    <EmptyDataTemplate>
    <asp:Image ID="im1" AlternateText="No Data" runat="server" />
        <br />
        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="new">New</asp:LinkButton>
    </EmptyDataTemplate>
    <HeaderStyle BackColor="gray">
    </HeaderStyle>
    <HeaderTemplate>
      <asp:Label runat="server" id="hdr1" width="330px" Text="Test" />
      <asp:Label runat="server" id="hdr2" Text="Update At" />
    </HeaderTemplate>
    <EditItemTemplate>
    <asp:DropDownList ID="int_list"
        width="330px"
        DataSourceID="ds_int"
        runat="server"
        name="desc"
        BackColor="gray"
        DataTextField="int_desc"
        DataValueField="int_desc"
        PropertyName="SelectedValue" >
    </asp:DropDownList>
    <asp:Textbox id="change_date" Text='<%# Bind("change_date") %>' runat="server" />
    <br />
    <asp:LinkButton ID="LinkButton4" runat="server" CommandName="update">Update</asp:LinkButton>
    &nbsp;<asp:LinkButton ID="LinkButton5" runat="server" CommandName="cancel">Cancel</asp:LinkButton>
    </EditItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource
    ID="ds_user_int" Runat="server"
    ConnectionString="<%$ ConnectionStrings:Mssqlconn2 %>"
    ProviderName="System.Data.SqlClient"
    SelectCommand="select int_desc,change_date from tab2 order by 1"
    Insertcommand="insert into tab2 (user_id,int_desc,change_date) values (cast(@userid as decimal(10,0)),@desc,@dt)" >
          <insertparameters>
              <asp:ControlParameter ControlID="lb_userid" Name="userid" PropertyName="Text" />
              <asp:ControlParameter ControlID="int_list" Name="desc" PropertyName="Text" />
              <asp:ControlParameter ControlID="change_date" Name="dt" PropertyName="Text" />
          </insertparameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource
    ID="ds_int" Runat="server"
    SelectCommand="select int_desc from tab3 where @age>20 and @sex='Male' order by 1"
    ConnectionString="<%$ ConnectionStrings:Mssqlconn2 %>"
    ProviderName="System.Data.SqlClient" >
        <SelectParameters>
            <asp:ControlParameter ControlID="lb_age" DefaultValue="0" Name="age"
                PropertyName="Text" />
            <asp:ControlParameter ControlID="rbl_sex" DefaultValue="M" Name="sex"
                PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br /><br />
    ...
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 38792049
try changing the controlparameter controlid attribute to :

 <asp:ControlParameter ControlID="int_fv$int_list" Name="desc" PropertyName="Text" />

you can find out what the controlid you need to specify is by right clicking the page and selecting view source to see what id has been assigned to the dropdownlist.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# LINQ ForEach() question 6 54
location of a form 2 25
how to just get time from a date 6 32
Input parameteres to DragOver 2 19
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

839 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