Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question on DropDownList values
Message
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01119302
Message ID:
01119314
Views:
13
This is what I was looking for:
for (int i =0;i < ddlSite.Items.Count ;i++ )
{		 
  Response.Write( ddlSite.Items[i].Value.ToString() );
}
>I have a drop down list bound to a view that has two columns.
>
>
>ddlSite.DataSource = dvSite;
>ddlSite.DataTextField = "SITE_DESC";
>ddlSite.DataValueField = "SITE_ID";
>ddlSite.DataBind();
>
>
>I am trying to find an item in the ddl by value using the following code:
>
>
>ListItem selectedItem = ddlSite.Items.FindByValue( "MyValue" );
>
>
>But the value of selectedItem is always NULL which means the item of Value "MyValue" not found. Right? And I think it is there.
>How do you I "scan" through values of the DDL using FOR EACH or something like this?
>
>Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform