Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error with the command

Posted on 2013-01-17
6
Medium Priority
?
436 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 11

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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 11

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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
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…

715 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