473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Using controls for sqlparameters from different containers asp.Net

Hi there,

I have a curious problem I can't seem to solve. I have a list box that gets
filled with data, the user selects an item in this list, then a form view
displays the full details from that list. The problem I have is that the
list box and the form are in different content placeholders, and I can't get
them to work together. I have this code:
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="SideContent">
<p>
<asp:SqlDataSource ID="SelectSupportingDocs" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [Title] FROM
[tblSupportingDocs]"></asp:SqlDataSource>
<asp:ListBox ID="lbSelectDocument" runat="server"
AutoPostBack="True" CssClass="ListBox" DataSourceID="SelectSupportingDocs"
DataTextField="Title" DataValueField="ID"></asp:ListBox>
</p>
</asp:Content>

<asp:Content ID="Content3" runat="server"
ContentPlaceHolderID="SupportingDoc">
<asp:FormView ID="FormView2" runat="server"
DataSourceID="SelectedSupportingDoc"

<EditItemTemplate></EditItemTemplate>
<InsertItemTemplate></InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="PageTextLabel" runat="server" Text='<%#
Bind("PageText") %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SelectedSupportingDoc" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [PageText] FROM [tblSupportingDocs] WHERE
([ID] = @ID)">
<SelectParameters>
<asp:ControlParameter ControlID="lbSelectDocument" Name="ID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>

From what I can see, the ControlParameter, controlID is set to the correct
control. However, when the page is run, I get an error " could not find
control lbSelectDocument in controlParameter ID".

I assume this is becuase they are in different containers. Can I reference
the control from it current location? (at the moment content2 is a side bar,
and content 3 is the main form).

Thanks for any help.
Jul 13 '06 #1
2 1383
Would also like to add, when the controls are in the same container, all
works well. In seperate containers, the error occurs. How can I get the
controlparameter control to get its data from another control in a different
container.

Container1.controlname.... didnt appear to work.

"Dynamo" wrote:
Hi there,

I have a curious problem I can't seem to solve. I have a list box that gets
filled with data, the user selects an item in this list, then a form view
displays the full details from that list. The problem I have is that the
list box and the form are in different content placeholders, and I can't get
them to work together. I have this code:
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="SideContent">
<p>
<asp:SqlDataSource ID="SelectSupportingDocs" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [Title] FROM
[tblSupportingDocs]"></asp:SqlDataSource>
<asp:ListBox ID="lbSelectDocument" runat="server"
AutoPostBack="True" CssClass="ListBox" DataSourceID="SelectSupportingDocs"
DataTextField="Title" DataValueField="ID"></asp:ListBox>
</p>
</asp:Content>

<asp:Content ID="Content3" runat="server"
ContentPlaceHolderID="SupportingDoc">
<asp:FormView ID="FormView2" runat="server"
DataSourceID="SelectedSupportingDoc"

<EditItemTemplate></EditItemTemplate>
<InsertItemTemplate></InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="PageTextLabel" runat="server" Text='<%#
Bind("PageText") %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SelectedSupportingDoc" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [PageText] FROM [tblSupportingDocs] WHERE
([ID] = @ID)">
<SelectParameters>
<asp:ControlParameter ControlID="lbSelectDocument" Name="ID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>

From what I can see, the ControlParameter, controlID is set to the correct
control. However, when the page is run, I get an error " could not find
control lbSelectDocument in controlParameter ID".

I assume this is becuase they are in different containers. Can I reference
the control from it current location? (at the moment content2 is a side bar,
and content 3 is the main form).

Thanks for any help.

Jul 13 '06 #2
Solution:

<asp:ControlParameter ControlID="lbSelectDocument" Name="ID"
PropertyName="SelectedValue" Type="Int32" />

ControlId should read "SideContent$lbSelectDocument"

Hi there,

I have a curious problem I can't seem to solve. I have a list box that gets
filled with data, the user selects an item in this list, then a form view
displays the full details from that list. The problem I have is that the
list box and the form are in different content placeholders, and I can't get
them to work together. I have this code:
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="SideContent">
<p>
<asp:SqlDataSource ID="SelectSupportingDocs" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [Title] FROM
[tblSupportingDocs]"></asp:SqlDataSource>
<asp:ListBox ID="lbSelectDocument" runat="server"
AutoPostBack="True" CssClass="ListBox" DataSourceID="SelectSupportingDocs"
DataTextField="Title" DataValueField="ID"></asp:ListBox>
</p>
</asp:Content>

<asp:Content ID="Content3" runat="server"
ContentPlaceHolderID="SupportingDoc">
<asp:FormView ID="FormView2" runat="server"
DataSourceID="SelectedSupportingDoc"

<EditItemTemplate></EditItemTemplate>
<InsertItemTemplate></InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="PageTextLabel" runat="server" Text='<%#
Bind("PageText") %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SelectedSupportingDoc" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [PageText] FROM [tblSupportingDocs] WHERE
([ID] = @ID)">
<SelectParameters>
<asp:ControlParameter ControlID="lbSelectDocument" Name="ID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
Jul 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe | last post by:
I'm wondering how to loop through controls in VB.NET. I have the code from VB6 ok, but I can't figure out how to do it correctly in .NET. This is an example from my VB6 code that loops through...
6
by: xzzy | last post by:
I need to automate a report in a different database. Dim RPT as Report Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Path & "\Mydb.mdb", True, False) For i = 0 To...
1
by: Jozef | last post by:
Hello, I'm trying to loop through forms by doing a "For Each" in the Currentdb. I'm doing this like the following; Dim db as dao.database Dim docLoop as document Dim ctrl as control Set db...
9
by: Peter Afonin | last post by:
Hello: I need to clear all textboxes on the webform after the data has been submitted. How can I do this in one step? I found a C# code: // get a reference to your form control Control frm...
3
by: Kelly Leahy | last post by:
I'm using an Asp:Repeater control with a text box in the item templates. This is for a system that has a number of items that the user can edit and I'd like to generate them based on a list. ...
2
by: Peter Jackson | last post by:
I'm using v2 of the UIP App. Block. I've created all my .aspx pages, all of which contain .ascx user controls. The .ascx user controls provide the standard server controls (i.e., LinkButtons, etc.)...
1
by: Jack | last post by:
Hi, I have a page with a repeater control that contains textboxes. I'm trying to create a validation class that is called by my page. A method in this class iterates through all the controls...
5
by: Gui | last post by:
Hi, I'm working in C# .net 2005 with Ajax. I have a page that loads dynamic user controls depending on the scenario. In those user controls, I create dynamic linkbuttons. The user controls are...
0
by: johnspruit | last post by:
I have a method to collect all the controls on a form, also the controls in containers on the form. It seems that some controls, like NumericUpDown also have child controls. I only want controls...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.