954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Cannot implicitly convert type 'string' to 'bool'

hi

i have just started learning ASP.Net..

i'm try to using dropdown list in if condition it gives error message as "Cannot implicitly convert type 'string' to 'bool'"

if (DropDownList1.SelectedItem.Text="buyername" )
{
            da = new SqlDataAdapter("select * from buyermaster where  buyername like '" + a + "%'", con);
            da.Fill(ds);
        }
Jega_k_k
Newbie Poster
1 post since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

I'm a VB guy, but I think c# uses ==

if (DropDownList1.SelectedItem.Text=="buyername" )
a496761
Junior Poster in Training
62 posts since Feb 2008
Reputation Points: 10
Solved Threads: 4
 

I'm a VB guy, but I think c# uses ==

if (DropDownList1.SelectedItem.Text=="buyername" )


yeah you are right he should have used double equal signs.

serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 

it worked out...use " == "

kani123
Newbie Poster
1 post since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You