Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp:ListItem Selected option not working

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
US

I have the following markup that doesn't work correctly.

I have the 2nd item selected but it still sets the 1st item as selected.

Why is that?

Code:
<asp:DropdownList ID="ddlActive" runat="server" >
   <asp:ListItem Value="">[All]</asp:ListItem>
   <asp:ListItem Value="1" Selected="True">Yes</asp:ListItem>
   <asp:ListItem Value="0" >No</asp:ListItem>
</asp:DropdownList>

Thanks,

Tom


 
I also tried to set it as:

ddlActive.ClearSelection();
ddlActive.Items.FindByText("Yes").Selected = true;

But this sets the dropdown as "No".

Tom
 
why not just simple
ddlActive.SelectedValue = "1";
on page_load? And do not forger !isPostBack


 
It sounds like you have some code somewhere that is overriding the Selected = "True
 
It was being overwritten. Not directly but the filters were saved and restored in the background.

Thanks,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top