Solved

Error with the command

Posted on 2013-01-17
6
432 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
[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
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

763 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