473,320 Members | 2,027 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,320 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 3889
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.