Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Server Error in '/SPMS' Application.

String was not recognized as a valid Boolean.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a valid Boolean.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +10757994
SportsPMS.Views.Home.PlayerEntryForm.LoadSportsPersonInfo(String Id, Boolean toEdit) in PlayerEntryForm.aspx.cs:1089
SportsPMS.Views.Home.PlayerEntryForm.Page_Load(Object sender, EventArgs e) in PlayerEntryForm.aspx.cs:35
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034
Posted
Comments
Thanks7872 8-Oct-13 3:59am    
So rest of the code is to be assumed by us,right?
MuhammadUSman1 8-Oct-13 6:26am    
Please past your code, and mention line when you getting error.
Your are converting string in Boolean, but the value of string is not (true,false), thats y this error occor
Anaya Upadhyay 8-Oct-13 7:03am    
The error is on the line 1089 and the code goes like this:

1089: bool myValue;
1090: if(Boolean.TryParse(drow["IsTrue"].ToString(), out myValue))
1010: this.genderCheckBox.Checked = true;
1011: else
1012: this.genderCheckBox.Checked = false;
MuhammadUSman1 8-Oct-13 7:12am    
know check my solution. you just didn't assign myValue,

Without showing your code, how could we give you solutions?

Check this post to solve the error.
String was not recognized as a valid Boolean[^]
 
Share this answer
 
Comments
Anaya Upadhyay 8-Oct-13 6:23am    
The error is on the line 1089 and the code goes like this:

1089: bool myValue;
1090: if(Boolean.TryParse(drow["IsTrue"].ToString(), out myValue))
1010: this.genderCheckBox.Checked = true;
1011: else
1012: this.genderCheckBox.Checked = false;
[no name] 8-Oct-13 7:26am    
Do one thing
First You have to ensure that what type of value is coming inside drow["IsTrue"]

For this put a breakpoint there select the drow["IsTrue"] statement and put Quick Watch and see is the value is boolean type ?
If not then check your database and your query to send a boolean value

I am telling beacause Your error is string is not valid boolean.

Finally you can do it in a plain way
genderCheckBox.Checked=Convert.ToBoolean(drow["IsTrue"]);
Check this code,

C#
//The error is on the line 
//1089 and the code goes like this: 

//assign myValue you can't use unassinged variables
1089: bool myValue=false;

1090: if(Boolean.TryParse(drow["IsTrue"].ToString(), out myValue)) 
1010: this.genderCheckBox.Checked = true; 
1011: else 
1012: this.genderCheckBox.Checked = false;

// you can use following code also
bool myValue=false;

Boolean.TryParse(drow["IsTrue"].ToString(), out myValue);
this.genderCheckBox.Checked = myValue; 
 
Share this answer
 
v2
Comments
Anaya Upadhyay 9-Oct-13 0:23am    
i've tried this. But the issue is, the same code runs in localhost but not in server (i mean when it is online).
MuhammadUSman1 9-Oct-13 0:38am    
Are you sure that the error occurring on this code?
after initializing myValue = false,
?
Anaya Upadhyay 9-Oct-13 5:49am    
100% sure

And i need to solve this within 12 hours. Please help.
As I said earlier, it runs well in localhost. But after hosting it on the Server the same line doesnot work.
MuhammadUSman1 9-Oct-13 23:51pm    
Sorry Anaya i am too late,
but i don't think so that there is any issue in code.
Please declare myValue as static and try,
Friends!! listen up, the code i wanted help with runs very well on Localhost. It does show error on the internet after I upload it on the web server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900