Determining the selected RadioButton in a RadioButtonList

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
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.
 
Hello Nathan,

You don't need the foreach loop. You can use RadioButtonList.SelectedItem
and/or RadioButtonList.SelectedIndex to determine the selected radiobutton.
 
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]" <briansMCSD@discussions.microsoft.com> wrote in messagenews:B904E08D-C98A-4FA7-8073-69EFB552E6B5@microsoft.com...> 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/>>>>>>
 
Back
Top