Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropDownList Item Selected doesn't work?

Reply
Thread Tools

DropDownList Item Selected doesn't work?

 
 
Rudy Ko
Guest
Posts: n/a
 
      04-27-2005
Hi,

I seem unable to set the selected item in a DropDownList by using the
following code, it always return the toppest (index 0) item, no matter what
i selected.

list.DataSource = GetProductDataSource();
list.DataBind();
item = list.Items.FindByValue("UMTS");
if(item != null)
item.Selected = true;
I steped into the code, and I'm sure that item has been set to true, but the
page still return the toppest item. Anyone can help??




 
Reply With Quote
 
 
 
 
Roger Helliwell
Guest
Posts: n/a
 
      04-28-2005
On Wed, 27 Apr 2005 12:00:27 -0400 in
microsoft.public.dotnet.framework.aspnet, "Rudy Ko" <(E-Mail Removed)>
wrote:

>Hi,
>
>I seem unable to set the selected item in a DropDownList by using the
>following code, it always return the toppest (index 0) item, no matter what
>i selected.
>
>list.DataSource = GetProductDataSource();
>list.DataBind();
>item = list.Items.FindByValue("UMTS");
>if(item != null)
> item.Selected = true;
>I steped into the code, and I'm sure that item has been set to true, but the
>page still return the toppest item. Anyone can help??
>

Try,

list.SelectedValue = "UMTS";

Roger

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help to fill textboxes from a selected item in datagrid-selected index changed. mldardy ASP .Net 0 09-28-2010 02:59 PM
Selected ListItem in DropDownList does not appear selected Nathan Sokalski ASP .Net Web Controls 0 10-05-2008 10:29 PM
Selected ListItem in DropDownList does not appear selected Nathan Sokalski ASP .Net 0 10-05-2008 10:29 PM
DropDownList 2 always returns Selected = 0 for all items - even selected item Iain ASP .Net 3 12-11-2006 11:07 AM
Getting te ID of a Selected Item in a dropdownlist. Rob Venable ASP .Net 4 01-21-2004 11:39 PM



Advertisments