I am getting a "Specified cast is not valid." when I try to default a value


I am getting a "Specified cast is not valid." when I try to default a...
Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Glad you got it going.  Smile
Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Well, now I am really surprised. All I did was add this line after setting the item_amt:

cboitem_fk.SelectedValue = boDefaultPrice.item_pk;

and the problem went away.

Sometimes I would rather be lucky than good Tongue


Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Hi all.

This should be something simple, but I don't know how to fix it.

here is the code:

private void cboitem_fk_SelectionChangeCommitted(object sender, EventArgs e)

{

if (boDefaultPrice.SeekToPrimaryKey( Convert.ToInt32(cboitem_fk.SelectedValue.ToString())))

boProposalCosts.item_amt = boDefaultPrice.item_amt;

}

the funny thing is that it displays the item price in the text box  and then the error is thrown and my combo box goes blank.

Here is the stack trace:

InvalidCastException
  Specified cast is not valid.

Source     : Trinity

Stack Trace:
   at Trinity.BusinessObjects.boProposalCosts.Field_item_fk_Descriptor.SetValue(Object component, Object Value) in F:\Trinity_new\Trinity\BusinessObjects\boProposalCosts.Designer.cs:line 651
   at System.Windows.Forms.BindToObject.SetValue(Object value)
   at System.Windows.Forms.Binding.PullData(Boolean reformat, Boolean force)
   at System.Windows.Forms.Binding.Target_PropertyChanged(Object sender, EventArgs e)
   at System.Windows.Forms.ListControl.OnSelectedValueChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectedValueChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
   at System.Windows.Forms.ComboBox.WndProc(Message& m)
   at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

What am I missing here? This should be sead simple.


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search