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

get value of dynamically added controls

I have a form to which I add sets of input controls ie. textbox 1,
dropdownlist 1, textbox 2, dropdownlist 1, textbox 3, dropdownlist 3.
The number of sets vary.

I give them unique IDs the following way: txt_1, ddl_1, txt_2, ddl_2,
txt_3, ddl_3.

When the form is submitted I retrieve the values of the dynamically
added controls by iterating over the request.form collection looking
for IDs txt_ and ddl_

Is there a better way to retrieve the values?

Morten
Nov 19 '05 #1
2 1578
For a known ID? no.

Even if you loop through controls, you will still have to match the values
to the IDs. Now, there is a potential of creating a hashtable to store names
and values at the same time you create the control and matching changed
values. If you can then pass this to a database as a "parameter collection",
you are golden. Realize, however, that this ease of "coding" can be murder on
performance with all of the boxing and unboxing that goes on.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"wapsiii" wrote:
I have a form to which I add sets of input controls ie. textbox 1,
dropdownlist 1, textbox 2, dropdownlist 1, textbox 3, dropdownlist 3.
The number of sets vary.

I give them unique IDs the following way: txt_1, ddl_1, txt_2, ddl_2,
txt_3, ddl_3.

When the form is submitted I retrieve the values of the dynamically
added controls by iterating over the request.form collection looking
for IDs txt_ and ddl_

Is there a better way to retrieve the values?

Morten

Nov 19 '05 #2
I see. So I should create some type of collection (arraylist), add the
IDs of the dynamically created controls as string properties to an
object. Add the objects to the collection. Then add the collection to
a session variable and then, when the form is submitted, reverse the
process: casting the session variable to the collection, and iterating
the collection of objects getting every ID and simply use the IDs to
precisely query reguest.form?
On Mon, 10 Oct 2005 09:26:05 -0700, "Cowboy (Gregory A. Beamer) - MVP"
<No************@comcast.netNoSpamM> wrote:
For a known ID? no.

Even if you loop through controls, you will still have to match the values
to the IDs. Now, there is a potential of creating a hashtable to store names
and values at the same time you create the control and matching changed
values. If you can then pass this to a database as a "parameter collection",
you are golden. Realize, however, that this ease of "coding" can be murder on
performance with all of the boxing and unboxing that goes on.

Nov 19 '05 #3

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

Similar topics

7
by: Piotr Strycharz | last post by:
Hi all. I have problem with ASP:DropDownList. I do not know how to get its value. The DropDownList is populated in Page_Load method (from SQL Server). When this list is embeded in ASPX page...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
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...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
3
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those...
5
by: Chris | last post by:
I have a page with mixture of static and dynamically added controls is there any way of controlling the order which they are added to the page. My submit button (statically added) appears before...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
6
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from the...
2
by: Dica | last post by:
i've got a script that creates a new tablerow + tablecell and appends that to a non dynamically created table control. a new row is added for each recordset returned from my sql statement. within...
5
by: Nathan Sokalski | last post by:
I have a custom control that I wrote (I inherit from System.Web.UI.WebControls.CompositeControl). I dynamically add this control to my Page, but I was told that dynamically added controls do not...
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
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...
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
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
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...

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.