473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

trouble converting RadioButtonList.SelectedValue into a string

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("rblGende r");
bool gender = bool.Parse(rbl.SelectedValue);

any suggestions?
Oct 7 '08 #1
2 2625


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uH**************@TK2MSFTNGP06.phx.gbl...
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("rblGende r");
bool gender = bool.Parse(rbl.SelectedValue);

any suggestions?
Yes. "0" and "1" are not booleans!

--
John Saunders | MVP - Connected System Developer

Oct 8 '08 #2
thanks, I changed to using "true", "false" instead
Oct 8 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hazzard | last post by:
I store radiobuttonlist values in the db using the string value of the radio button item value. (nvarchar) I am creating an edit functionality on the asp.net form so that when I reuse my...
4
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater...
2
by: Serg | last post by:
Hello, I need to set the selection in the RadioButtonList according to the value of SelectedValue in the underlying dataset - please suggest. The code is below. Thank you. <asp:TemplateColumn>...
5
by: Mike Salter | last post by:
I created a page that reads a DB for questions and possible answers (usuallyYes/No). I create a panel for each group of questions, and add a panel for each question to the Group panel. To the...
1
by: Jay | last post by:
On my aspx page I have a FormView with a RadioButtonList bound to a column on a DataSource table. The form starts up in Edit mode. I want the formView to start up with nothing yet selected in the...
5
by: Øyvind Isaksen | last post by:
I'm making a page to update articles. When a radiobuttonlist is displayed, I want the stored value to be displayed as default (checked). Example: I use a procedure to display the...
1
by: Daspiffy | last post by:
I have a radioButtonList that works perfectly until I add a masterpage. The original code was: string temp = Request; After reading some other posts I tried all of the following...
6
by: SAL | last post by:
hello, I'm using a radiobuttonlist in an updatepanel in an item template in a Gridview control. I'm populating the radiobuttonlist in the RowDataBound event. I have the control toolkit registered...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.