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);
        }

Recommended Answers

All 3 Replies

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

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

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.

it worked out...use " == "

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.