title: asp.net datalist nested with RadioButtonList on Postback are always NOT SELECTED
body: <p>I have a asp.net which contains a datalist and inside its itemtemplate it contains a radiobuttonlist</p>
  
  <p>Here is my ASPX code:</p>
  
  <pre><code>&lt;asp:DataList ID="dtlQuestions" runat="server" RepeatDirection="Vertical" DataKeyField="ID" OnItemDataBound="dtlQuestions_ItemDataBound"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Label ID="q" runat="server" Text='&lt;%# Eval("Question") %&gt;'&gt;&lt;/asp:Label&gt;
          &lt;asp:RadioButtonList ID="dtlAnswers" runat="server" ValidationGroup='Bla' RepeatDirection="Horizontal" RepeatColumns="5" CssClass="radioButtonList"&gt;
          &lt;/asp:RadioButtonList&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>In the code behind, I have a list of "Questons" which each item contains a list of Items.
  I bind the questions to the Datalist, and each answer inside question is binded to the radioButtonList.</p>
  
  <p>Here is the C# code:</p>
  
  <pre><code>protected void dtlQuestions_ItemDataBound(object sender, DataListItemEventArgs e)
  {
      SurveyQuestion drv = e.Item.DataItem as SurveyQuestion;
      RadioButtonList RadioButtonList1 = (RadioButtonList)e.Item.FindControl("dtlAnswers");
      foreach (QuestionAnswer a in drv.QuestionAnswers)
      {
          ListItem i = new ListItem();
          i.Text = a.Answer;
          i.Value = a.Answer;
          RadioButtonList1.Items.Add(i);
      }
  }
  </code></pre>
  
  <p><strong>Now my problem is when on a button click I want to go back and read every radiobutton and see if it is checked or not, I am able to loop through the radiobuttons but all are showing not selected.</strong></p>
  
  <p>Here is the button submit click</p>
  
  <pre><code>protected void btnSubmit_Click(object sender, EventArgs e)
  {
      DataList dtlQuestions = Page.FindControl("dtlQuestions") as DataList;
  
      foreach (DataListItem question in dtlQuestions.Items)
      {
          RadioButtonList rdList = question.FindControl("dtlAnswers") as RadioButtonList;
  
          foreach (ListItem answer in rdList.Items)
          {
              bool isSelected = answer.Selected;
          }
      }
  }
  </code></pre>