Solved

Error with the command

Posted on 2013-01-17
6
428 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 29

Expert Comment

by:Paul Jackson
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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:…
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…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 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

10 Experts available now in Live!

Get 1:1 Help Now