title: Dynamically add ListItem to RadiobuttonList with proper ID in ASP.NET
body: <p>I'm trying to dynamically add radio buttons from code behind. I add it by calling the following code:</p>
  
  <pre><code>    private void AddRadioButtonList(string id, bool isBool)
      {
          RadioButtonList radioButtonList = new RadioButtonList();
          radioButtonList.ID = id;
          form1.Controls.Add(radioButtonList);
          if (isBool) { GenerteTrueFalseListItems(radioButtonList); }
          form1.Controls.Add(new LiteralControl("&lt;br /&gt;"));
      }
  </code></pre>
  
  <p>When <code>isBool</code> is true, the following function is called:</p>
  
  <pre><code>    private void GenerteTrueFalseListItems(RadioButtonList item)
      {
          item.Items.Clear();
          item.Items.Add(new ListItem("True", "true"));
          item.Items.Add(new ListItem("False", "false"));
      }
  </code></pre>
  
  <p>But radio buttons on page are missing correct IDs, and I can select only one radio button from whole page.</p>
  
  <p><a href="https://i.stack.imgur.com/188rT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/188rT.png" alt="radio buttons rendered wrong on page"></a></p>
  
  <p>I am expecting the IDs of the radio buttons to be either "true" or "false".</p>
  
  <p>What should I do in order to have radio buttons rendered correctly?</p>