StrataFrame Forum

Error System.ArgumentOutOfRangeException: Value of '-1' is not valid for 'Value'. 'Value' should be between

http://forum.strataframe.net/Topic20305.aspx

By Leonard P. - 10/23/2008

Hi,

I am getting a Framework error (see more info below), when opening maintenance form from the main window:



ProductMaintenance maintForm = new ProductMaintenance(this.factSheetReportBO.Product_Id);

maintForm.ShowDialog(this);




The main window passes in PK_ID and maintenance form navigates to that ID. The error only happens for one specific PK ID. There's nothing special about this ID, I can't figure out why it would fail on that ID.

By looking at the error message can you tell me what can be causing it, or at least point me to the right direction?





System.ArgumentOutOfRangeException: Value of '-1' is not valid for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'.\rParameter name: Value\r at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)\r at System.Windows.Forms.Binding.SetPropValue(Object value)\r at System.Windows.Forms.Binding.PushData(Boolean force)\r at System.Windows.Forms.Binding.UpdateIsBinding()\r at System.Windows.Forms.Binding.CheckBinding()\r at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase)\r at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding)\r at System.Windows.Forms.BindingsCollection.Add(Binding binding)\r at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding)\r at System.Windows.Forms.Control.UpdateBindings()\r at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)\r at System.Windows.Forms.ContainerControl.

OnCreateControl()\r at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r at System.Windows.Forms.Control.CreateControl()\r at System.Windows.Forms.Control.WmShowWindow(Message& m)\r at System.Windows.Forms.Control.WndProc(Message& m)\r at System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r at System.Windows.Forms.ContainerControl.WndProc(Message& m)\r at System.Windows.Forms.Form.WmShowWindow(Message& m)\r at System.Windows.Forms.Form.WndProc(Message& m)\r at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)\r at System.Windows.Forms.Control.ControlN

ativewindow.WndProc(Message& m)\r at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"


By Edhy Rijo - 10/23/2008

Hi Leonard,

System.ArgumentOutOfRangeException: Value of '-1' is not valid for 'Value'.

It looks like your this.factSheetReportBO.Product_Id value is -1 which means that you are adding a record and the PK has not been saved, you may want to either make sure your Product_Id is a valid PK at the calling form.

By Trent L. Taylor - 10/23/2008

Well, I would assume from looking at the message that you have this field bound to something.  Possibly  a numeric up down control with a Min and Max range.  It may not be this field but another that is bound.  That would be the first place I would look.
By Leonard P. - 10/24/2008

Trent L. Taylor (10/23/2008)
Well, I would assume from looking at the message that you have this field bound to something. Possibly a numeric up down control with a Min and Max range. It may not be this field but another that is bound. That would be the first place I would look.




Trent, that was exactly it!!! I spent hours looking at the code and form's controls. And you nailed it right away without seeing my form! You are a genius!!! Thank you!
By Trent L. Taylor - 10/24/2008

LOL...glad you found it Smile