473,382 Members | 1,814 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,382 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 3896
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...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.