473,770 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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" ContentPlaceHol derID="SideCont ent">
<p>
<asp:SqlDataSou rce ID="SelectSuppo rtingDocs" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [ID], [Title] FROM
[tblSupportingDo cs]"></asp:SqlDataSour ce>
<asp:ListBox ID="lbSelectDoc ument" runat="server"
AutoPostBack="T rue" CssClass="ListB ox" DataSourceID="S electSupporting Docs"
DataTextField=" Title" DataValueField= "ID"></asp:ListBox>
</p>
</asp:Content>

<asp:Content ID="Content3" runat="server"
ContentPlaceHol derID="Supporti ngDoc">
<asp:FormView ID="FormView2" runat="server"
DataSourceID="S electedSupporti ngDoc"

<EditItemTempla te></EditItemTemplat e>
<InsertItemTemp late></InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="PageTextLab el" runat="server" Text='<%#
Bind("PageText" ) %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSou rce ID="SelectedSup portingDoc" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [PageText] FROM [tblSupportingDo cs] WHERE
([ID] = @ID)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="lbSe lectDocument" Name="ID"
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>
</asp:Content>

From what I can see, the ControlParamete r, controlID is set to the correct
control. However, when the page is run, I get an error " could not find
control lbSelectDocumen t in controlParamete r 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 1403
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
controlparamete r control to get its data from another control in a different
container.

Container1.cont rolname.... 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" ContentPlaceHol derID="SideCont ent">
<p>
<asp:SqlDataSou rce ID="SelectSuppo rtingDocs" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [ID], [Title] FROM
[tblSupportingDo cs]"></asp:SqlDataSour ce>
<asp:ListBox ID="lbSelectDoc ument" runat="server"
AutoPostBack="T rue" CssClass="ListB ox" DataSourceID="S electSupporting Docs"
DataTextField=" Title" DataValueField= "ID"></asp:ListBox>
</p>
</asp:Content>

<asp:Content ID="Content3" runat="server"
ContentPlaceHol derID="Supporti ngDoc">
<asp:FormView ID="FormView2" runat="server"
DataSourceID="S electedSupporti ngDoc"

<EditItemTempla te></EditItemTemplat e>
<InsertItemTemp late></InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="PageTextLab el" runat="server" Text='<%#
Bind("PageText" ) %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSou rce ID="SelectedSup portingDoc" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [PageText] FROM [tblSupportingDo cs] WHERE
([ID] = @ID)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="lbSe lectDocument" Name="ID"
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>
</asp:Content>

From what I can see, the ControlParamete r, controlID is set to the correct
control. However, when the page is run, I get an error " could not find
control lbSelectDocumen t in controlParamete r 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:ControlPar ameter ControlID="lbSe lectDocument" Name="ID"
PropertyName="S electedValue" Type="Int32" />

ControlId should read "SideContent$lb SelectDocument"

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" ContentPlaceHol derID="SideCont ent">
<p>
<asp:SqlDataSou rce ID="SelectSuppo rtingDocs" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [ID], [Title] FROM
[tblSupportingDo cs]"></asp:SqlDataSour ce>
<asp:ListBox ID="lbSelectDoc ument" runat="server"
AutoPostBack="T rue" CssClass="ListB ox" DataSourceID="S electSupporting Docs"
DataTextField=" Title" DataValueField= "ID"></asp:ListBox>
</p>
</asp:Content>

<asp:Content ID="Content3" runat="server"
ContentPlaceHol derID="Supporti ngDoc">
<asp:FormView ID="FormView2" runat="server"
DataSourceID="S electedSupporti ngDoc"

<EditItemTempla te></EditItemTemplat e>
<InsertItemTemp late></InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="PageTextLab el" runat="server" Text='<%#
Bind("PageText" ) %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSou rce ID="SelectedSup portingDoc" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [PageText] FROM [tblSupportingDo cs] WHERE
([ID] = @ID)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="lbSe lectDocument" Name="ID"
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>
</asp:Content>
Jul 13 '06 #3

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

Similar topics

3
2584
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 controls in a specific frame on a form and unselects the option buttons. .NET barks at this line of code: thiscontrol.value = False Private Sub UnSelectOpts(ByVal passedframeCaption As String) Dim thiscontrol As Control For Each thiscontrol In Me...
6
1542
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 MyDB.Containers(5).Documents.Count - 1 If MyDB.Containers(5).Documents(i).Name = "MyReport" Then
1
6442
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 = CurrentDb
9
12913
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 = FindControl("YourFormID"); foreach(Control ctrl in frm.Controls)
3
2055
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. However, when the user clicks a save button (not in the asp:repeater, but on the form itself) I would like to (on postback) update the values in the database and redisplay the page. I can't figure out how to reference the controls generated by...
2
1809
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.) for the user to navigate the site and perform their tasks. None of the site's actual functionality is contained in the .aspx pages--they're just kinda containers for all the .ascx user controls. So, I'm to the point in the UIP App. Block where I...
1
4725
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 on the page. On encountering a TextBox control, it looks at the ID to discern the field the TextBox represents, and then creates the appropriate validation controls and adds them to the page. The controlToValidate property of each validation...
5
1858
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 loaded on the .aspx PageLoad and the linkbuttons are created on the .ascx PageLoad. The problem I have is that those linkbuttons don't work on the first click. I have to make 2 clicks to have their event fired. What can I do for that ? Thanks.
0
1095
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 form 'real' containers. How can i do that? thanks
0
9595
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8891
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.