I'm using FormView in Asp.net 4.5 to edit entity model like this:
<asp:FormView runat="server" ....>
<EditItemTemplate>
.....
<asp:DropDownList runat="server" SelectedValue='<%# BindItem.value %>'>
</asp:DropDownList>
.....
</EditItemTemplate>
</asp:FormView>
If BindItem.value is one of the values in DropDownList items this works perfectly, but if BindItem.value was ,for example, null or any value out of range, this will raise an exception like this:
Selection out of range
Parameter name: value
Is there a way to let DropDownList selects first item if BindItem.value is wrong?