Determining the selected RadioButton in a RadioButtonList

N

Nathan Sokalski

I have a RadioButtonList as one of the Controls in the ItemTemplate of my
DataList. I am using a For Each loop to go through the Items property, but
even if one of the RadioButtons has been selected, they all return False.
What am I doing wrong? Thanks.
 
G

Guest

Hello Nathan,

You don't need the foreach loop. You can use RadioButtonList.SelectedItem
and/or RadioButtonList.SelectedIndex to determine the selected radiobutton.
 
N

Nathan Sokalski

I tried the following code:

For Each question As DataListItem In Me.datQuestions.Items
System.Diagnostics.Debug.WriteLine(CType(question.FindControl("rblQuestions"),RadioButtonList).SelectedValue)NextBut it returned nothing. I think the reason I am having so much trouble isbecause of the ID that is generated when the page is created. I know thatthere is a way to programmatically determine this using the ClientIDproperty. What change do I need to make to my code? Thanks.--Nathan (e-mail address removed)://www.nathansokalski.com/"brians[MCSD]" <[email protected]> wrote in messagenews:[email protected]...> Hello Nathan,>> You don't need the foreach loop. You can use RadioButtonList.SelectedItem> and/or RadioButtonList.SelectedIndex to determine the selectedradiobutton.>> --> brians> http://www.limbertech.com>>> "Nathan Sokalski" wrote:>>> I have a RadioButtonList as one of the Controls in the ItemTemplate of my>> DataList. I am using a For Each loop to go through the Items property,but>> even if one of the RadioButtons has been selected, they all return False.>> What am I doing wrong? Thanks.>> -->> Nathan Sokalski>> (e-mail address removed)>> http://www.nathansokalski.com/>>>>>>
 

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,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top