473,397 Members | 2,056 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,397 software developers and data experts.

multiple dynamic controls with properties

Hello,

Ive searched all over the net trying to find an answer to this...so
anybody with some expertise in this area would be greatly appreciated.

Background:
I have a webform that loads a datagrid. This datagrid has a button in
a column that loads another datagrid(user control) when clicked. This
new grid also has a column with a button that loads another user
control. So, there could be 3 user controls on this form if all the
buttons are pushed.

Problem:
The first two controls load fine...but when the button is pushed on
the second control, it disappears and only the first control loaded
onto the page is left. I know this happens due to the way asp.net
loads controls, etc.

Question:
How do I get this to work, so that I can dynamically load as many
controls as I want on the page, as well as set properties for the
controls?
Code Issues:
Each control loaded on the page has its own properties that are set in
the button event. For example, the second control loaded on the page
has an itemid property that is set when the first control runs the
button event. That button event from the first control basically runs
the following code:

public void showItem(object
sender,System.Web.UI.WebControls.CommandEventArgs e)
{

//create a control for item info
Control ctrl = new Control();
string szID = e.CommandArgument.ToString();
//its an asset
ctrl = (Inventory.Controls.assetinfo) LoadControl
(Request.ApplicationPath + Path.AltDirectorySeparatorChar +
"Controls/assetinfo.ascx");
((Inventory.Controls.assetinfo)ctrl).ItemID = szID;
phItemInfo.Controls.Add(ctrl);
}
That control also has a similar method to load a control to show user
information.
**How can I dynamically load the controls...and set their properties,
so that each control remains on the page? Ive tried using the
viewstate, sessions, etc., but nothing seems to allow me to load all
three of these controls while still being able to set their
properties.

Let me know if I need to provide any more info. Thanks again for any
ideas!

x B. Rubble x
Nov 18 '05 #1
2 1321


B.,

As you may have found, you have to keep track
of what controls you have loaded and load them again
when a postback occurs.

This might be kind of involved in your scenario.
If you have a limited number of different controls you
might want to have them hard-coded on the page and
just make them visible as needed.

Also consider this:
http://groups.google.com/groups?hl=e...8&selm=O8RSb.1
985%24HO2.1960%40news.edisontel.com

Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Thanks for the reply!

I tried the link you provided but it didnt solve the issue,
unfortunately. Ive thought about preloading all the controls on the
page and making them visible when needed, but the controls have
properties, so Im not sure how to load the control before I know what
its property value will be.

Ive also tried to store the controls in a databag of sorts which works
to some degree but still has issues...mostly viewstate issues it
appears.

Seems like there should be an easy way to do this, but Ive asked all
the experts where I work, and they cant seem to come up with a
solution that is scaleable.

Any MVPs out there seen this kind of issue???

Thanks again!

Jim Corey <jc****@nospamcharter.net> wrote in message news:<#d**************@tk2msftngp13.phx.gbl>...
B.,

As you may have found, you have to keep track
of what controls you have loaded and load them again
when a postback occurs.

This might be kind of involved in your scenario.
If you have a limited number of different controls you
might want to have them hard-coded on the page and
just make them visible as needed.

Also consider this:
http://groups.google.com/groups?hl=e...8&selm=O8RSb.1
985%24HO2.1960%40news.edisontel.com

Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

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

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
2
by: robert112 | last post by:
This is quite a hard one guys. ***Some necessary back ground Info*** I have an asp.net 1.1 application that uses a WYSIWYG to return some html created by the user in the admin section of the...
4
Frinavale
by: Frinavale | last post by:
Introduction Sometimes, when developing web applications, we need to be able to dynamically load controls based on user selections. The following article describes a simple scenario where TextBox...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
5
by: Hans Kesting | last post by:
Hi, Is there good information about the asp.net page lifecycle in combination with dynamically loaded controls? Or on "how to build dynamic controls"? I keep hitting problems where values are...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.