trouble converting RadioButtonList.SelectedValue into a string

Discussion in 'ASP .Net' started by Jeff, Oct 8, 2008.

  1. Jeff

    Jeff Guest

    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, Oct 8, 2008
    #1
    1. Advertising

  2. "Jeff" <> wrote in message
    news:...
    > 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!

    --
    John Saunders | MVP - Connected System Developer
    John Saunders, Oct 8, 2008
    #2
    1. Advertising

  3. Jeff

    Jeff Guest

    thanks, I changed to using "true", "false" instead
    Jeff, Oct 8, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. thinkmast

    RadioButtonList SelectedValue

    thinkmast, May 7, 2006, in forum: .NET
    Replies:
    0
    Views:
    3,487
    thinkmast
    May 7, 2006
  2. Arnold

    how to get selectedvalue of radiobuttonlist in Javascript?

    Arnold, Nov 12, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    2,209
    Arnold
    Nov 12, 2006
  3. Replies:
    0
    Views:
    151
  4. Replies:
    1
    Views:
    186
    nandha
    Mar 29, 2005
  5. Arnold
    Replies:
    6
    Views:
    370
    MikeS
    Nov 12, 2006
Loading...

Share This Page