By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,983 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,983 IT Pros & Developers. It's quick & easy.

control scope problem

P: n/a
the error returned is this:

Server Error in '/AnnAccRpt' Application.
--------------------------------------------------------------------------------

Could not find control 'DropDownList1' in ControlParameter 'DropDownList1'.
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
'DropDownList1' in ControlParameter 'DropDownList1'.

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 'DropDownList1' in
ControlParameter 'DropDownList1'.]
System.Web.UI.WebControls.ControlParameter.Evaluat e(HttpContext context,
Control control) +566
System.Web.UI.WebControls.Parameter.UpdateValue(Ht tpContext context,
Control control) +43
System.Web.UI.WebControls.ParameterCollection.Upda teValues(HttpContext
context, Control control) +104
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control) +36

System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +265
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +237
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values,
IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.FormView.HandleUpdate(St ring commandArg,
Boolean causesValidation) +1151
System.Web.UI.WebControls.FormView.HandleEvent(Eve ntArgs e, Boolean
causesValidation, String validationGroup) +450
System.Web.UI.WebControls.FormView.OnBubbleEvent(O bject source, EventArgs
e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEven t(Object source,
EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String
eventArgument) +156

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4916

My code is pretty basic, all I did was from within vis web dev express, drop
a formView onto my page and allocate a sqldatasource to it.
The source has a join in the query.
the edit form of the form view has a dropdownlist that pulls from a
different datasource but the selectedValue comes from the main sql query.
I thought that in order to make my update query take the selectedvalue from
the dropdown box that I would use the @dropdownlist in the update query.
by default when you use the GUI to add the update query it just puts regular
parameter tags, not the controlparameter tags... so I changed them.
If I can use the automated process HOW?
CODE:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AnnAccRptConnectionString %>"
SelectCommand="SELECT Projects.GroupID,
ClientGroups.GroupName, Projects.ProjID, Projects.year, Projects.Client,
Projects.Title, Projects.Narative, Projects.ProposalID FROM ClientGroups
INNER JOIN Projects ON ClientGroups.GroupID = Projects.GroupID"
UpdateCommand="update projects set GroupID = @DropDownList1
where ProjID = @ProjID">
<UpdateParameters>
<asp:controlParameter ControlID="DropDownList1"
Name="DropDownList1" PropertyName="SelectedValue" />
<asp:controlParameter ControlID="ProjIDTextBox"
Name="ProjID" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
<asp:FormView ID="FormView1" runat="server"
DataSourceID="SqlDataSource1">
<EditItemTemplate>
<br />
Group:
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource2"
DataTextField="GroupName" DataValueField="GroupID"
SelectedValue='<%# Bind("GroupID") %>'>
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2"
runat="server" ConnectionString="<%$
ConnectionStrings:AnnAccRptConnectionString %>"
SelectCommand="SELECT [GroupID], [GroupName] FROM
[ClientGroups]"></asp:SqlDataSource>

<br />
ProjID:
<asp:TextBox ID="ProjIDTextBox" runat="server" Text='<%#
Bind("ProjID") %>'></asp:TextBox><br />
year:
<asp:TextBox ID="yearTextBox" runat="server" Text='<%#
Bind("year") %>'></asp:TextBox><br />
Client:
<asp:TextBox ID="ClientTextBox" runat="server" Text='<%#
Bind("Client") %>'></asp:TextBox><br />
Title:
<asp:TextBox ID="TitleTextBox" runat="server" Text='<%#
Bind("Title") %>'></asp:TextBox><br />
Narative:
<asp:TextBox ID="NarativeTextBox" runat="server" Text='<%#
Bind("Narative") %>'></asp:TextBox><br />
ProposalID:
<asp:TextBox ID="ProposalIDTextBox" runat="server" Text='<%#
Bind("ProposalID") %>'></asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
GroupID:
<asp:TextBox ID="GroupIDTextBox" runat="server" Text='<%#
Bind("GroupID") %>'>
</asp:TextBox><br />
GroupName:
<asp:TextBox ID="GroupNameTextBox" runat="server" Text='<%#
Bind("GroupName") %>'>
</asp:TextBox><br />
ProjID:
<asp:TextBox ID="ProjIDTextBox" runat="server" Text='<%#
Bind("ProjID") %>'>
</asp:TextBox><br />
year:
<asp:TextBox ID="yearTextBox" runat="server" Text='<%#
Bind("year") %>'>
</asp:TextBox><br />
Client:
<asp:TextBox ID="ClientTextBox" runat="server" Text='<%#
Bind("Client") %>'>
</asp:TextBox><br />
Title:
<asp:TextBox ID="TitleTextBox" runat="server" Text='<%#
Bind("Title") %>'>
</asp:TextBox><br />
Narative:
<asp:TextBox ID="NarativeTextBox" runat="server" Text='<%#
Bind("Narative") %>'>
</asp:TextBox><br />
ProposalID:
<asp:TextBox ID="ProposalIDTextBox" runat="server" Text='<%#
Bind("ProposalID") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
GroupID:
<asp:Label ID="GroupIDLabel" runat="server" Text='<%#
Bind("GroupID") %>'></asp:Label><br />
GroupName:
<asp:Label ID="GroupNameLabel" runat="server" Text='<%#
Bind("GroupName") %>'></asp:Label><br />
ProjID:
<asp:Label ID="ProjIDLabel" runat="server" Text='<%#
Bind("ProjID") %>'></asp:Label><br />
year:
<asp:Label ID="yearLabel" runat="server" Text='<%#
Bind("year") %>'></asp:Label><br />
Client:
<asp:Label ID="ClientLabel" runat="server" Text='<%#
Bind("Client") %>'></asp:Label><br />
Title:
<asp:Label ID="TitleLabel" runat="server" Text='<%#
Bind("Title") %>'></asp:Label><br />
Narative:
<asp:Label ID="NarativeLabel" runat="server" Text='<%#
Bind("Narative") %>'></asp:Label><br />
ProposalID:
<asp:Label ID="ProposalIDLabel" runat="server" Text='<%#
Bind("ProposalID") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:FormView>
</form>
</body>
</html>

Jan 27 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.