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

Looping to find dynamic control values c#

Can someone help me figure this out...

I've created dropdown boxes dynamically and added them to a panel on my
page.

how do i get the selectedvalue of the dropdownlist from the panel when i
click the submit button?

I've tryed :
pnlName.Controls[0]
to see if that would find the dropdownlist control but says:
Specified argument was out of the range of valid values. Parameter name:
index

Thanks in advance
Mike
Nov 16 '05 #1
2 3899
Could you post the code that causes this failure? I suspect you havent
added it to the controls collection of the panel

Mike wrote:
Can someone help me figure this out...

I've created dropdown boxes dynamically and added them to a panel on my
page.

how do i get the selectedvalue of the dropdownlist from the panel when i
click the submit button?

I've tryed :
pnlName.Controls[0]
to see if that would find the dropdownlist control but says:
Specified argument was out of the range of valid values. Parameter name:
index

Thanks in advance
Mike


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
Nov 16 '05 #2
I figured it out with a foreach loop as follows:

foreach(Control ctrl in pnlOptionDdl.Controls)

{

DropDownList ddl = ctrl as DropDownList;

if(ddl!=null){

HttpContext.Current.Response.Write(ddl.SelectedIte m.Text.ToString());

}

}

Thanks though :)

"Dilip Krishnan" <dilipdotnet..NOSPAM..@apdiya.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Could you post the code that causes this failure? I suspect you havent
added it to the controls collection of the panel

Mike wrote:
Can someone help me figure this out...

I've created dropdown boxes dynamically and added them to a panel on my
page.

how do i get the selectedvalue of the dropdownlist from the panel when i
click the submit button?

I've tryed :
pnlName.Controls[0]
to see if that would find the dropdownlist control but says:
Specified argument was out of the range of valid values. Parameter name:
index

Thanks in advance
Mike


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com

Nov 16 '05 #3

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

Similar topics

4
by: Colin Steadman | last post by:
I've create a simple survey using ASP. Its finished and works, but one aspect of my coding is annoying me and I cant figure out a better way of doing it. Basically the questions are stored in...
1
by: tascien | last post by:
I have a user control that has dynamic controls loaded to it in Page_Init. this works well. I have a function inside the user control: GetValues() When i add this usercontrol to a page:...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
by: Mike | last post by:
Can someone help me figure this out... I've created dropdown boxes dynamically and added them to a panel on my page. how do i get the selectedvalue of the dropdownlist from the panel when i...
2
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page...
1
by: Ryan | last post by:
Hello. I was hoping that someone may be able to assist with an issue that I am experiencing. I have created an Access DB which imports an Excel File with a particular layout and field naming. ...
6
by: Luke - eat.lemons | last post by:
Hi, Im pretty new to asp so all light on this question would be great. Basically i need to test to see what value is set (where to retrieve the data from) so ive done it like this: If...
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...
1
by: Robocop | last post by:
Having just started using C again after some years off, i've been stumped by a problem i think someone more experienced could probably solve pretty easily. I have these 4 objects (vectors), and i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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,...

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.