Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Time to get some help on this. I have a comboboxedit control that has a requery event taking three integer parameters. The FillDataTable method in the BO looks like this: public void FillByOrderIndex(int pPLType, int pMasterIndex, int pAddrIndex) { SqlParameter mPLType = new SqlParameter("@pltype", pPLType); SqlParameter mMasterIndex = new SqlParameter("@masterindex", pMasterIndex); SqlParameter mAddrIndex = new SqlParameter("@addrindex", pAddrIndex); FillByStoredProcedure("spx_GetOrderItemList", mPLType, mMasterIndex, mAddrIndex); }This actually works (thanks for the help earlier this week!). The problem comes in when the combobox hits one of the resulting columns. It is the "orderid" field. It gets to the following code:
[Browsable(false), BusinessFieldDisplayInEditor(), Description(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public System.Int32 orderid { get { return (System.Int32)this.CurrentRow["orderid"]; <--*** OFFENDING CODE *** } set { this.CurrentRow["orderid"] = value; } } The get_orderid() method kicks out a "Specified cast is not valid" error. If I place the parameters into the SQL Query Analyzer, I get a result set that does have an orderid and it is an integer value. Any ideas about what I should do or where to look for a solution?
Thanks!! Bill
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Have you put a break point on that line and investigated what the value of this.CurrentRow["orderid"] is?
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Yup...that is why this is so baffling...the loValue variable is reflecting the value of the integer field properly. Yet, the stack trace shows that get_orderid method throws a specified cast is not valid error. Scratches head (again).
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Sorry...I changed the field to return a 0 on null, so the code looks like this, now: [ Browsable(false), BusinessFieldDisplayInEditor(), Description(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public System.Int32 orderid { get { object loValue; loValue = this.CurrentRow["orderid"]; if (loValue == DBNull.Value) { return 0; } else { return (System.Int32)loValue; } } set { this.CurrentRow["orderid"] = value; } }
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
This fixed it or this is what the code looks like now? I see nothing obviously wrong. The most likely problems are either the BO is empty (in which case CurrentRow is null) or the value of the field is DbNull.Value, which you're taking care of.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Still broken. I am still trying to change one thing at a time to correct the problem (very time-consuming). So far, no success. Thanks for pitching in, Greg. I am sure I did something wrong that is quite simple and easily overlooked. I see a "Doh!" moment coming soon. Bill
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Here is the error report: InvalidCastException Specified cast is not valid. Source : System Stack Trace: at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) at System.Windows.Forms.Binding.SetPropValue(Object value) at System.Windows.Forms.Binding.PushData(Boolean force) at System.Windows.Forms.Binding.UpdateIsBinding() at System.Windows.Forms.Binding.CheckBinding() at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase) at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding) at System.Windows.Forms.BindingsCollection.Add(Binding binding) at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding) at System.Windows.Forms.Control.UpdateBindings() at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e) at System.Windows.Forms.ContainerControl.OnCreateControl() at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.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)
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Did you set the FieldPropertyDescriptor for this property?
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Not exactly sure what you are talking about...sorry. After you mentioned that, though, I went into the DDT and edited my (non-database) table. I put a description in each column (same as the name). Partial built and this is now the code in the BO for the orderid: [ Browsable(false), BusinessFieldDisplayInEditor(), Description("orderid"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public System.Int32 orderid { get { object loValue; loValue = this.CurrentRow["orderid"]; if (loValue == DBNull.Value) { return 0; } else { return (System.Int32)loValue; <<--- BOMBS HERE! } } set { this.CurrentRow["orderid"] = value; } }I am building and running now...stand by... Btw, I blew away the combobox and added a grid, bo and bbs. No matter what I do, the orderid bombs. Here is the error: System.InvalidCastException was unhandled by user code Message="Specified cast is not valid." Source="AspireModel" StackTrace: at Aspire.Model.OrderItemListBO.get_orderid() in C:\Aspire Projects\AspireSF\AspireModel\OrderItemListBO.Designer.cs:line 315 at Aspire.Model.OrderItemListBO.Field_orderid_Descriptor.GetValue(Object component) in C:\Aspire Projects\AspireSF\AspireModel\OrderItemListBO.Designer.cs:line 575 at DevExpress.Data.Helpers.BaseListDataControllerHelper.GetRowValue(Int32 listSourceRow, Int32 column) at DevExpress.Data.DataController.GetRowValue(Int32 controllerRow, Int32 column) at DevExpress.Data.BaseListSourceDataController.GetRowValue(Int32 controllerRow, Int32 column) at DevExpress.XtraGrid.Views.Base.ColumnView.GetRowCellValue(Int32 rowHandle, GridColumn column) at DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(Int32 rowHandle, GridColumn column) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellDrawInfo(GridDataRowInfo ri, GridColumnInfoArgs ci, GridCellInfo cell, GridColumnInfoArgs nextColumn, Boolean calcEditInfo) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellsDrawInfo(GridDataRowInfo ri, GridColumnsInfo columnsInfo) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcDataRow(GridDataRowInfo ri, GridRow row, GridRow nextRow) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowsDrawInfo() at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcGridInfo() at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc(Graphics g, Rectangle bounds) at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout() at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout() at DevExpress.XtraGrid.Views.Grid.GridView.LayoutChanged() at DevExpress.XtraGrid.Views.Base.BaseView.EndUpdateCore(Boolean synchronized) at DevExpress.XtraGrid.GridControl.EndUpdate(Boolean synchronized)
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Take a look at this post, you've got the property setup, just wondering if you also added the field property descriptors for any custom fields: http://forum.strataframe.net/FindPost13027.aspx
|
|
|