Syntax for adding new list item?

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

Guest

If have a dropdown control and have set this to the first position of the
dropdown":
ddUserRole.Items.Insert(0, "Select Role...");

But, I want to be able to set the value of the above item to zero. I
thought it was this:
ddUserRole.Items.Insert(0, New ListItem("0","Select Role..."));

but it doesn't seem to be the case. I get the squigly line under ListItem.
Can anyone help out with the correct syntax?
 
Should be right.

is System.Web.UI.WebControls imported?

What's the actual error?

Karl
 
That's what I thought too. Forgot to mention this is an ASP 2.0 app.
The squiggly line appears under ListItem and under the last parenthesis.

The error for the ListItem is: ") expected"
The errors for the last paren are: "; expected" and "Invalid expression
term ')'"
double quotes are not part of the error.
 
If have a dropdown control and have set this to the first position of the
dropdown":
ddUserRole.Items.Insert(0, "Select Role...");

But, I want to be able to set the value of the above item to zero. I
thought it was this:
ddUserRole.Items.Insert(0, New ListItem("0","Select Role..."));

but it doesn't seem to be the case. I get the squigly line under
ListItem.
Can anyone help out with the correct syntax?

That's because C# is case-sensitive - change "New" to "new" and all will be
well again...
 
lol..I don't feel too bad about missing it...I've gotten used to text
editors capitalizing code when they ought note...just read past it now..

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top