iterate through set of controls in code behind on postback

G

Guest

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
 
K

Kevin Spencer

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
 
G

Guest

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__
---_,>/'_------
(_) \(_)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top