SelectedValue in dropdownlist - invalid item but no exception

  • Thread starter Thread starter John
  • Start date Start date
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
 
PS. I have the June 06 CTP of Atlas installed (but the problem also occurs
in apps that don't use Atlas)
 
Back
Top