Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Looping thru a controls collection to get properties of that contr

Thread Tools

Looping thru a controls collection to get properties of that contr

Posts: n/a
I'm very new to ASP.Net programing, so I hope I can explain what I want to do.
I used the following code to create anywhere from 1 to 16 radiobuttonlist in
a placeholder, each with two "listitems" added to each. What I want to do is
check to see what item the user picked for each of the radiobuttonlists.
For I=2 to FldCount step 2
If myreader.IsDbNull(i)=False then
Dim myRBList As RadioButtonList = New RadioButtonList()
myRBList.ID = "ID" & i
myrblist.items.add(myreader.getstring(i + 1))
end if
next I
dim oControl as control
For Each oControl In Placeholder1.Controls
If TypeOf ocontrol Is radiobuttonlist Then
"Once here how do I get to the collection that contains the
items selected"
End If

If anyone knows of any good websites/articles that can explain controls
collection or show how to iterate thru them, I would appreciate it.

Reply With Quote
Wilco Bauwer
Posts: n/a
1. I would use a databound control instead, such as a Repeater. In that
case you can do most of your stuff declaratively, and you don't have to
take control recreation into account (upon postbacks). So it's less
error prone too.
2. Upon a postback, you can check a radio button list's Selected*

In case you don't want to go for 1., you have to take into account that
adding a control dynamically, means that the control is ONLY added to
the control hierachy for the CURRENT request. So upon a postback, its
NOT there anymore, and you have to RECREATE it. If you dont do this
properly, you'll have problems with events not being fired, etc.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) ěyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Looping thru controls - part 2!! Craig G ASP .Net 6 02-24-2005 01:03 PM
Looping thru all controls on a WebForm Craig G ASP .Net 5 02-22-2005 03:02 PM
DataGrid.UpdateCommand Can't Get Updated Values From Textbox Contr =?Utf-8?B?TmV3YXNwcw==?= ASP .Net 0 06-12-2004 10:20 PM