473,414 Members | 1,954 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,414 software developers and data experts.

Dynamically Load User Control

Greetings,

I have a user control, that I will need to display on a specific page
based on the number of records in database:

I have to query a site table to get the number of entries as well as a
specific column field for each entry. I then pass that to the user
control to grab a specific set of information from another table and
display.

I have the user control all setup to do this based on a variable passed
to it, but I am not sure how to get the user control to display on the
page more than once without adding it in there manually. Which in the
long run will not be very good to have to edit the code everytime we
add a site...

Any help or examples appreciated.

Thanks!

-Kevyn

May 25 '06 #1
3 9222
you have add refference to your user control as you insert it from
designer....

after this from code you can do this:

MyUserControl ctrl = new MyUserControl();
Page.Control.Add(ctrl); // instead page here can be any container

hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com

May 25 '06 #2
Thanks for the response. I sorta got it working the way I need, but
have one little issue still...

On my control page, I have a asp:datasource setup that seems to work if
I pass the paramter in for the where the clause, but whenever I try to
pass the table to get the data from, it errors out on me. Below is the
code from the control page:

<asp:SqlDataSource ID="dsGetSites" runat="server" ConnectionString="<%$
ConnectionStrings:CRM_SystemConnection %>"
SelectCommand="SELECT [campaign_id],[campaign_name],[prod_id],
[type], [isActive] FROM @site_code ">
<SelectParameters>
<asp:Parameter Name="site_Code" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

I can supply the full code for both pages if needed to help in solving
this problem I am having.

May 25 '06 #3
Actually..Let me break this down a little bit so it makes more sense to
myself and to whomever can help :-)

1. I have a query that gets 2 columns from a table.

2. For the total number of results (x), I need to pass those 2 values
to a custom control so that it appears (x) amount of times on a page.

Thanks in advance!

May 25 '06 #4

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

Similar topics

7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
1
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
2
by: A.Wussow | last post by:
Hi Everybody, i want to load dynamically content from some user controls (with forms, or some data-controls) using atlas. So i use an UpdatePanel for loading the user control into a placeholder....
2
by: Nick | last post by:
I have two navigation user controls and based on a query string will load one or the other. On the page that will load the user control I cannot do the following Dim uc As FlashNavigation (The...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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,...
0
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...

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.