add value for dropdown list in asp.net

liunx

Guest
when i try to use the dropdown

dropdown_State.Itemes.Add("CA")
and the result when viewing html code is
<option value="CA">CA</option>
Now, I want the result to be like
<option value="CA">California</option>
Please helpAre you using the state abriviations like ("CA") elsewhere in your application?
If not, just use:dropdown_State.Itemes.Add("California").

If you are, do you have a databse that you can make a quick "State" table with? I'd do that with the state abriviation as the id, and add name field. Bind your ddl to the name field.Use the following code:
ListItem li =new ListItem();
li.value="CA";
li.Text="California";
Then add this list item to dropdownlist
as
dropdownlist1.Items.Add(li);you can also try this, it would be easier:
dropCategory.Items.Add( New ListItem( "California", "CA" ) ) ;)

Hope this helps;
 
Back
Top