3

In asp.net web form-I have added group of radio button dynamically in web form and on clicking submit button when i try to the find the radio button button with its id using find.control(id), it returns null. Can some body help me am new to asp.net?

RadioButton myControl1 = (RadioButton)Page.FindControl("r11");
mason
  • 31,774
  • 10
  • 77
  • 121
user3290395
  • 29
  • 1
  • 6

1 Answers1

4

Two reasons.

When you add controls dynamically, you must re-add them when the page posts back (In Page_Init is a good place). See How to persist a dynamic control

The other is that Page.FindControl() only goes one level down, you need to recursively search down the list. See Better way to find control in ASP.NET

Community
  • 1
  • 1
mason
  • 31,774
  • 10
  • 77
  • 121
  • In oder to re add them how do i know which checked boxes are checked?.My question is, dynamically added radio button is checked and on submit i couldn't find the control to get its check property. – user3290395 Feb 10 '14 at 17:39