Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone help?

In this following coding I got this Error "String was not recognized as a valid Boolean" where - " if (Convert.ToBoolean( condition = "<500"))"
C#
public void price()
{
    if (Convert.ToBoolean( condition = "<500"))
    {
        SqlCommand cmd = new SqlCommand("select pro_img,pro_name,price from product where price='" + price_range + "' and status='A' and type='retail'", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList1.DataSource = ds;
        DataList1.DataBind();
    }

}
Posted
Updated 21-Nov-11 21:01pm
v3
Comments
R. Giskard Reventlov 22-Nov-11 2:55am    
No, no one can help with the information you have supplied: you'll need to be more specific and display some code since no one here is telepathic.

Try changing the operator:
C#
if (Convert.ToBoolean( condition = "<500"))
Becomes
C#
if (Convert.ToBoolean( condition == "<500"))

In fact, dump the Convert bit altogether:
C#
if (condition == "<500")
 
Share this answer
 
Comments
R. Giskard Reventlov 22-Nov-11 3:08am    
Beat me to it! Take a 5!
RaisKazi 22-Nov-11 3:15am    
5ed. My guess of int type was wrong.
Even your updated details does not provide all the details.

If your condition variable is of int type, then modify your code as below. No need to use Convert.ToBoolean.
C#
if (condition < 500)

Otherwise let us know, what is a Type of condition variable.
 
Share this answer
 
v2
Comments
sathiyak 22-Nov-11 3:10am    
i gave condition as string......
RaisKazi 22-Nov-11 3:14am    
If "condition" variable is a type of string then please refer Griff's answer(Solution 1).

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



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