WebForms - BO.Add method causes error with DropDownList


Author
Message
Jiri Brazda
Jiri Brazda
StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)StrataFrame User (146 reputation)
Group: StrataFrame Users
Posts: 78, Visits: 356

Hi,

I'm using WebForms with DropDownList (actually I have two DropDownLists - one has PopulationType set to Enumerator and second BusinessObject). Everything works fine - navigation througs records, editing, saving, deleting - all works fine. All except adding new row. When I click on the Add button and call BO.Add method, the error below my post occurs. When I remove these two dropdowns and there only remains textboxes, checkboxes etc. - the BO.Add method doesn't produce any error and I can add new records without problems.

Finally - I have found a workaround that I can use in some of forms but not all:

I use one form for searching and navigation through records and one for editing. The editing form doesn't allow any navigation. On Page_Load event of the editing form I check whether I should read record from DB by primary key or add new record - and in this moment I call BO.Add method and it works fine with DropDowns.

However, I need to use searching, navigation and editing in single form.

Any solution, please?

Thanks

Here is the error message:

 

Server Error in '/' Application.

 

'ddBPaID' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'ddBPaID' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentOutOfRangeException: 'ddBPaID' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value]   System.Web.UI.WebControls.ListControl.set_SelectedValue(String value) +1827674[TargetInvocationException: Exception has been thrown by the target of an invocation.]   System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0   System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +371   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29   System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +96   System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) +24   MicroFour.StrataFrame.Business.TypePropertyCache.SetPropertyValue(Type OwnerType, Object Owner, String PropertyName, Object Value, String FormatString) +260   MicroFour.StrataFrame.Business.TypePropertyCache.SetPropertyValue(Object Owner, String PropertyName, Object Value) +82   MicroFour.StrataFrame.Business.BusinessLayer.PushDataToWebControl(IWebBusinessBindable ControlToBind, IWebBinding Binding) +273   MicroFour.StrataFrame.Business.BusinessLayer.BindDataToWebControl(IWebBusinessBindable ControlToBind, IWebBinding Binding) +1024   MicroFour.StrataFrame.Business.BusinessLayer.BindDataToWebControlPrimary(IWebBusinessBindable ControlToBind) +46   MicroFour.StrataFrame.UI.Web.BasePage.BindControls() +224[UIException: An error occurred while binding data to the web control 'ddBPaID'.]   MicroFour.StrataFrame.UI.Web.BasePage.BindControls() +577   MicroFour.StrataFrame.UI.Web.BasePage.Page_PreRender(Object sender, EventArgs e) +30   System.Web.UI.Control.OnPreRender(EventArgs e) +2117836   System.Web.UI.Control.PreRenderRecursiveInternal() +86   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

 


Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Jiri Brazda - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Jiri Brazda - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Jiri Brazda - 16 Years Ago
                         Jiri, I missed this post, sorry :blush: It works just like the...
Trent L. Taylor - 16 Years Ago
                             Trent, thank You, this solution is really easy and it works...
Jiri Brazda - 16 Years Ago
                                 Glad it got you what you needed...and sorry you had to wait so long...
Trent L. Taylor - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search