SelectedValue in dropdownlist - invalid item but no exception

J

John

If you set DropDownList.SelectedValue to an item not in the list, shouldn't
an exception be thrown? ie:

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
</asp:DropDownList>

Then in the codebehind:

DropDownList1.SelectedValue = "999";

No exception is thrown, but the docs say:

"The SelectedValue property can also be used to select an item in the list
control by setting it with the value of the item. If no items in the list
control contain the specified value, a System.ArgumentOutOfRangeException is
thrown."

XP Pro sp2. ASP.NET 2.0 (VS2005 Team Edition for Soft Devs). C# 2.0. All the
latest updates.

Thanks,

John
 
J

John

PS. I have the June 06 CTP of Atlas installed (but the problem also occurs
in apps that don't use Atlas)
 

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

Top