control scope problem

G

Guest

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.Evaluate(HttpContext context,
Control control) +566
System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context,
Control control) +43
System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext
context, Control control) +104
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
context, Control control) +36

System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +265
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(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(String commandArg,
Boolean causesValidation) +1151
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +450
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs
e) +88
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source,
EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +86
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +156

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,490
Latest member
Finplus

Latest Threads

Top