Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error using C#

Status
Not open for further replies.

scottydd

IS-IT--Management
Sep 19, 2002
31
US
I'm new to C#, and this will probably be a simple question. I am trying to do a simple IF statement, based on a DDL selection.

if ( ddl_type.SelectedItem.Text = "COMMERCIAL" ) {
Response.Write(BinNo);
}

When i do this I get the following error:
CS0029: Cannot implicitly convert type 'string' to 'bool'

Can anyone help?

Thanks,
Scott
 
ddl_type.SelectedItem.Text == "COMMERCIAL"

should be == not =
 
easy mistake, this too will work
ddl_type.SelectedItem.Text.Equals("COMMERCIAL")
Marty

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top