trouble converting RadioButtonList.SelectedValue into a string

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?
 
J

John Saunders

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top