How is it that after years of using ASP.NET - I still run into things that baffle me? It’s par for the course I guess… but it’s still a bit frustrating.
In this case, I ran into a little problem when creating a form… specifically with the radio buttons on the form. This particular form had multiple groups of two radio buttons together, so I threw in a bunch of individual RadioButton server controls that looked basically like this:
<asp :RadioButton ID="rdoPayOption1" GroupName="PaymentOption" Text="Payment Option 1" runat="server"/> <asp :RadioButton ID="rdoPayOption2" GroupName="PaymentOption" Text="Payment Option 2" runat="server"/>
However, when the form was submitted... there were no values sent for the radio buttons - even though they had been checked. Plus, when I redisplayed the form (after the validation failed), the radio buttons did not stay checked. After many attempts at getting it working, I finally decided to try the RadioButtonList control:
<asp :RadioButtonList ID="rdoListQuarterPanel" runat="server"> <asp :ListItem Text="Payment Option 1" Value="Pay1" /> <asp :ListItem Text="Payment Option 2" Value="Pay2" /> </asp>
Wallah! Problem solved.