Exception Details: System.ArgumentOutOfRangeException: 'cboOrderStates' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
DropDownList cboOrderStates = (DropDownList)I guess that when I try to reference the DropDownList, it binds (or realizes it has already been bound) to my BO's OrderState property. This is on an Edit page, so the BO's property loads with a non-null value, and since I haven't populated the DropDownList yet, it chokes up. Honestly, though, I could be completely wrong about that. Either way, I would really appreciate some help figuring out how to overcome this. If it helps, here's the line in my .aspx file that binds the DropDownList to my BO's OrderState property:
FormView1.Row.FindControl("pnlPageContent").FindControl("cboOrderStates");
cboOrderStates.DataSource = BindToEnum(typeof(Order.OrderStates)); // Hashtable
cboOrderStates.DataBind();
Adam,
I'm not a ASP developer but Rocky did a post last year on converting on building an namevaluelist from an Enumerator. You would then use this instead to do your binding rather than the Enumerator. Sample population of NVL where Enumerator is defined in Btier.Enumerators.States as follows:
Private
Overloads Sub DataPortal_Fetch(ByVal criteria As Criteria)Try
Me.RaiseListChangedEvents = FalseIsReadOnly =
False For Each CurrentState As BTier.Enumerators.States In System.Enum.GetValues(GetType(BTier.Enumerators.States))Add(
New Csla.NameValueListBase(Of Integer, String).NameValuePair(CurrentState, _System.Enum.GetName(
GetType(BTier.Enumerators.States), CurrentState))) NextIsReadOnly =
True Me.RaiseListChangedEvents = True Catch Ex As Exception Throw Ex End Try End SubCopyright (c) Marimer LLC