Loop through controls

B

brian

I have many controls on a page. I name some txt1, txt2,
txt3, txt4, txt5 so I could loop through them.

Is there a way to find these controls, loop through them
to get there value(txt1.text) and assign a new value?

I would like to ignore all other controls on the page.

Thanks
 
K

Kevin Spencer

Dim objControl As Control
For Each objControl in ControlName.Controls...

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
G

Guest

Brian, something like this will work (vb syntax)

Dim myTextBox As TextBo
For Each ctl As Control In Page.Control
If TypeOf (ctl) Is TextBox The
myTextBox = CType(ctl, TextBox
' do whatever if myTextBox.ID is one I want, etc
End I
Nex

hth

Bil

----- brian wrote: ----

I have many controls on a page. I name some txt1, txt2,
txt3, txt4, txt5 so I could loop through them

Is there a way to find these controls, loop through them
to get there value(txt1.text) and assign a new value

I would like to ignore all other controls on the page

Thank
 

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

Top