RadioButton OnCheckChanged not firing on first time click

Someone on a Q&A forum was having issue where he had a RadioButton inside a GridView. The RadioButton had AutoPostBack=”true” and had OnCheckChanged event setup.

The issue he was facing was when he selected the RadioButton item first time, it won’t select and the OnCheckChanged event won’t fire. The selection was doing a postback but won’t fire the event. The selection was lost. Now if he selects the item again, it would work fine.

After looking at his code thoroughly I noticed he was setting the ID of the RadioButton in the code-behind.

Since the ID was changed late in the page life cycle, upon first postback, the event wasn’t recognized.

No Comments