trouble converting RadioButtonList.SelectedValue into a string

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hey

asp.net 2.0

When I execute my code I get an exception error saying: "String was not
recognized as a valid Boolean"
<asp:RadioButtonList ID="rblGender" Width="100%"
RepeatDirection="Horizontal" runat="server">
<asp:ListItem Text="Male" Selected="True" Value="1" />
<asp:ListItem Text="Female" Value="0" />
</asp:RadioButtonList>

It is on the second line below where the error is
RadioButtonList rbl = (RadioButtonList)tblEditUser.FindControl("rblGender");
bool gender = bool.Parse(rbl.SelectedValue);

any suggestions?
 
Jeff said:
Hey

asp.net 2.0

When I execute my code I get an exception error saying: "String was not
recognized as a valid Boolean"
<asp:RadioButtonList ID="rblGender" Width="100%"
RepeatDirection="Horizontal" runat="server">
<asp:ListItem Text="Male" Selected="True" Value="1" />
<asp:ListItem Text="Female" Value="0" />
</asp:RadioButtonList>

It is on the second line below where the error is
RadioButtonList rbl =
(RadioButtonList)tblEditUser.FindControl("rblGender");
bool gender = bool.Parse(rbl.SelectedValue);

any suggestions?

Yes. "0" and "1" are not booleans!
 
Back
Top