J
J055
Hi
I have a DropDownList databound in a FormView and getting data from an
ObjectDataSource. The data sometimes contains some values which are not in
the list of items and so gives me an ArgumentOutOfRangeException on binding.
I would like to intercept this value and check if it is in the list of items
first so I can null it or replace with an empty string. What's the best way
to do this?
Thanks
Andrew
<aspropDownList ID="TitleDropDownList" runat="server" SelectedValue='<%#
Bind("Title") %>' OnDataBound="TitleDropDownList_DataBinding">
<asp:ListItem Selected="True" Value="">Select...</asp:ListItem>
<asp:ListItem>Mr</asp:ListItem>
<asp:ListItem>Mrs</asp:ListItem>
<asp:ListItem>Miss</asp:ListItem>
<asp:ListItem>Ms</asp:ListItem>
<asp:ListItem>Dr</asp:ListItem>
<asp:ListItem>Prof</asp:ListItem>
</aspropDownList>
I have a DropDownList databound in a FormView and getting data from an
ObjectDataSource. The data sometimes contains some values which are not in
the list of items and so gives me an ArgumentOutOfRangeException on binding.
I would like to intercept this value and check if it is in the list of items
first so I can null it or replace with an empty string. What's the best way
to do this?
Thanks
Andrew
<aspropDownList ID="TitleDropDownList" runat="server" SelectedValue='<%#
Bind("Title") %>' OnDataBound="TitleDropDownList_DataBinding">
<asp:ListItem Selected="True" Value="">Select...</asp:ListItem>
<asp:ListItem>Mr</asp:ListItem>
<asp:ListItem>Mrs</asp:ListItem>
<asp:ListItem>Miss</asp:ListItem>
<asp:ListItem>Ms</asp:ListItem>
<asp:ListItem>Dr</asp:ListItem>
<asp:ListItem>Prof</asp:ListItem>
</aspropDownList>