title: dynamically use radio buttons in asp.net applications
body: <p>I am developping an asp.net application. </p>
  
  <p>When a user clicks on a page, some radio buttons are added to the the page dynamically.</p>
  
  <p>Then when he clicks on another "update" button, I would liek to check, which of the radio buttons are checked and post back them to the server.</p>
  
  <p>The problem is the following:</p>
  
  <p>I add dynamically the radio buttons in the page_load method.</p>
  
  <p>But when I am on the update button onclick method, I cannot use them to check if they are checked ot not. </p>
  
  <p>I have tried several methods like using a static dictionary of radiobuttons, but I cannot keep a reference on them, when I am on my update method.</p>
  
  <p>This is my method when the page is loading:</p>
  
  <pre><code>private static Dictionary&lt;string,RadioButton&gt; buttons;
  
  protected void Page_Load(object sender, EventArgs e)
  {
      for (int i=0;i&lt;5;i++)
      {
          RadioButton r = new RadioButton();
          r.Text = i.ToString();
          r.ID = i.ToString();;
          Panel1.Controls.Add(r);
          buttons.Add(i.ToString(), r);
      }
  }
  </code></pre>
  
  <p>And this is my method when the user click on the update button where I would like to access to each of my radiobutton depending their id or their text, but I cannot :
  For example, If I want all the buttons from 1 to 3 to be checked :</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      for (int i=1;i&lt;4;i++)
      {
          buttons[i].checked=true;
      }
  }
  </code></pre>