title: Adding new eventHandler in RadioButton CheckedChanges in dynamic table
body: <p>I'm trying to add another <code>eventHandler</code> to <code>RadioButton</code>. This is the sample code (which is working):</p>
  
  <p>ASP.NET:</p>
  
  <pre><code>&lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
  &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
  &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      RadioButton RB1 = new RadioButton();
      RB1.ID = "1";
      RB1.GroupName = "bla";
      RB1.CheckedChanged += new EventHandler(CheckedChanged);
      RadioButton RB2 = new RadioButton();
      RB2.ID = "2";
      RB2.GroupName = "bla";
      RB2.CheckedChanged += new EventHandler(CheckedChanged);
      PlaceHolder1.Controls.Add(RB1);
      PlaceHolder1.Controls.Add(RB2);
  
  }
  protected void CheckedChanged(object sender, EventArgs e)
  {
      Label1.Text = ((RadioButton)sender).ID;
  }
  </code></pre>
  
  <p>In my project I have dynamic creating of <code>RadioButtons</code> (the number of rows I get from database). The same adding <code>eventHandler</code> does not work, but if I write</p>
  
  <pre><code>MyRadioButton.Load += new EventHandler(Another_method);
  </code></pre>
  
  <p>The <code>Another_method</code> will start, but in</p>
  
  <pre><code>MyRadioButton.CheckedChanged += new EventHandler(Main_method);
  </code></pre>
  
  <p>the <code>Main_method</code> will not start if I choose one of the <code>RadioButtons</code>.
  What is wrong?</p>
  
  <hr>
  
  <p>@KevinP
  This is my code:</p>
  
  <pre><code>    Table tb1 = new Table();
      PlaceHolder1.Controls.Add(tb1);
      TableRow tr = new TableRow();
      TableCell tc = new TableCell();
      //adding the first row with title"
      tr.Cells.Add(tc);
      for (int i = 0; i &lt; ((ArrayList)(result[0])).Count; i++)
      {
          tc = new TableCell();
          Label example = new Label();
          example.Text = ((columnsResultFromSqlClients)(i)).ToString();
          tc.Controls.Add(example);
          tr.Cells.Add(tc);
      }
      tb1.Rows.Add(tr);
      //filling the table
      for (int i = 0; i &lt; result.Count; i++)
      {
          tr = new TableRow();
          tc = new TableCell();
          //adding radio button
          RadioButton RB = new RadioButton();
          RB.Attributes.Add("value", ((ArrayList)(result[i]))[0].ToString());
          RB.GroupName = "for_selecting";
          RB.ID = ((ArrayList)(result[i]))[0].ToString();
          RB.CheckedChanged += new EventHandler(RB_CheckedChanged2);
          //RB.AutoPostBack = true;
  
          RB.Attributes.Add("AutoPostBack", "True");
          tc.Controls.Add(RB);
          tr.Cells.Add(tc);
          //adding content
          for (int j = 0; j &lt; ((ArrayList)(result[i])).Count; j++)
          {
              tc = new TableCell();
              Label example = new Label();
              example.Text = ((ArrayList)(result[i]))[j].ToString();
              tc.Controls.Add(example);
              tr.Cells.Add(tc);
          }
          tb1.Rows.Add(tr);
      }
  </code></pre>
  
  <p>If I use <code>RB.AutoPostBack = true;</code>, I have no time to press the button to submit my choice, cause the page will reload when i click the one of the Radio Buttons.
  Also the <code>RB_CheckedChanged2</code> code:</p>
  
  <pre><code>protected void RB_CheckedChanged2(object sender, EventArgs e)
  {
      RadioButton tempRB = (RadioButton)sender;
      if (tempRB.Checked)
      {
          selected_id = tempRB.ID;
      }
  }
  </code></pre>
  
  <p>The <code>select_id</code> is a <code>static int</code> varible with standart value = "-1".</p>