add dropdown problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm adding an item to a dropdownlist control using the following code,

NumberList.Items.Add( New ListItem( "Country Music", "country" ) )

Compiler Error Message: CS1026: ) expected

What's wrong?
 
The constructor for Items.Add only takes 1 parameter. You need to create an
instance of a ListItem and populate it, then pass the ListItem object as a
parameter.

-James
 
I'm adding an item to a dropdownlist control using the following code,

NumberList.Items.Add( New ListItem( "Country Music", "country" ) )

Compiler Error Message: CS1026: ) expected

If this is *exactly* the code you are trying to compile, you need a
lowercase 'new', since C# is case-sensitive. "New" is not a keyboard,
thus the compiler sees New as a variable, and a space where it expected
a comma or parenthesis.

If that's not the problem, where does the compiler claim it expects the ")"?

--Mike
 
Back
Top