Solved

Error with the command

Posted on 2013-01-17
6
429 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
This article will show, step by step, how to integrate R code into a R Sweave document
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
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…

776 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