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

iterate through set of controls in code behind on postback

Let's say I rendered a bunch of controls with the same name and different IDs.
On postback, can I somehow iterate through these controls (checkboxes in
this case, but could be dropdown controls in the future) and get their values
and IDs
with all this done in the code behind page?
A small example would be appreciated.
Thanks,
Oleg
Nov 19 '05 #1
2 1930
Sure, but you would want to use a recursive function to do this ideally, as
you may have nested Controls. Every Control has a Controls Collection, which
you can, of course, loop through. So, you create a function that takes a
Control as a parameter, loops through each of the Controls in its Controls
Collection, and calls itself for each Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"Oleg" <Ol**@discussions.microsoft.com> wrote in message
news:49**********************************@microsof t.com...
Let's say I rendered a bunch of controls with the same name and different
IDs.
On postback, can I somehow iterate through these controls (checkboxes in
this case, but could be dropdown controls in the future) and get their
values
and IDs
with all this done in the code behind page?
A small example would be appreciated.
Thanks,
Oleg

Nov 19 '05 #2
I did something like this

Private Sub seperateControls(ByVal Cntrl As Control)

If Cntrl.Controls.Count > 0 Then

Dim contrl As Control
For Each contrl In Cntrl.Controls

seperateControls(contrl)

Next

Else
'setTooltipValue(Cntrl)
End If

End Sub

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
"Oleg" wrote:
Let's say I rendered a bunch of controls with the same name and different IDs.
On postback, can I somehow iterate through these controls (checkboxes in
this case, but could be dropdown controls in the future) and get their values
and IDs
with all this done in the code behind page?
A small example would be appreciated.
Thanks,
Oleg

Nov 19 '05 #3

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

Similar topics

2
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted...
3
by: Cathie | last post by:
Hi All, I have a few user controls on a page and I need to determine which control caused the PostBack. Is there anyway to do this? Thanks in advance, Cathie
4
by: Tom Wisnowski | last post by:
Hello all, Here is a simple example of what I'm doing... Create a ASPX page Add a PlaceHolder(plch) and a Button(btn) to the page. In the code behind on Page_load add the following......
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
4
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle...
0
by: Sue | last post by:
I'm missing something very simple here, and I need an answer fairly quick if possible. I'm behind on this project now because of this... Code examples below question... I have a datagrid (DG)...
1
by: Mike | last post by:
Hi, I am having troubles dealing with dynamically created WebControls. I have this HTML code: <form id="Form1" runat="server" method="post"> <table width="960" align="center"> <tr> <td...
1
by: Bjorn Sagbakken | last post by:
With ASP.NET 2.0: I have managed to create controls dynamically in an asp:table, populating them with database info, and even adding empty rows of controls for adding new data to the database....
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?

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.