Reputation: 39
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");
Upvotes: 3
Views: 9416
Reputation: 32694
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
Upvotes: 4