Ticket T311588
Visible to All Users

grid summary error >> "Speciefied cast is not valid"

created 9 years ago

Hi, i have grid with datasource based on xpdataview:

C#
XPDataView xpDataView1 = new XPDataView(); xpDataView1.PopulateProperties(unitOfWork1.GetClassInfo<ERPDocumentPositionPrimaryData>()); xpDataView1.LoadData(GetSalesData()); gridControl1.DataSource = xpDataView1;

where ERPDocumentPositionPrimaryData object is :

C#
[NonPersistent] public class ERPDocumentPositionPrimaryData : XPLiteObject { [Key] public int id; [Size(40)] public string twkod; public double realQuantity; public double realValue; public DateTime dkdatasp; public DateTime dkdata; [Size(40)] public string dkkod; public int dkid; public int khid; public int twid; [Size(40)] public string khkod; public int dplp; public double dpcena; }

it works ok until i add total summary for  any type (summary, avarage) for any of column: realQuantity, realValue, dpcena. then i get "Speciefied cast is not valid") .

all of that field are in database (MsSQL 2012) set as float.

C#
System.InvalidCastException occurred HResult=-2147467262 Message=Unable to cast object '11,00' of type 'Decimal' from type 'Object' to type 'Nullable`1'. (Original Message: Specified cast is not valid.), (column Index: 2), (column Name: 'realQuantity'), (column Caption: 'real Quantity'), (column Type: System.Double), (column Unbound: False), (column UnboundExpression: ""), (PropertyDescriptor: DevExpress.Xpo.DataViewPropertyDescriptor), (PropertyDescriptor Name: 'realQuantity'), (PropertyDescriptor PropertyType: System.Double), (PropertyDescriptor ComponentType:System.Object[]), (expectedReturnType: System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]) Source=DevExpress.Data.v15.1 StackTrace: at DevExpress.Data.Helpers.GenericDelegateHelper.InvalidCastVerboseLogger.Impl`2.LoggedCast(Func`2 nakedCast, A arg, Func`1 exceptionAuxInfoGetter) InnerException: System.InvalidCastException HResult=-2147467262 Message=Specified cast is not valid. Source=DevExpress.Data.v15.1 StackTrace: at DevExpress.Data.Helpers.GenericDelegateHelper.UnboxingConversionCreator.Impl`1.Unbox(Object arg) at DevExpress.Data.Helpers.GenericDelegateHelper.InvalidCastVerboseLogger.Impl`2.LoggedCast(Func`2 nakedCast, A arg, Func`1 exceptionAuxInfoGetter) InnerException:

Could you help me why is that ? data type seem ok and coupled correctly. i try to change format of sum from SUM={0:0.##} to SUM={0} (since i have similar problem with sum of timespan) but it do not help.

Help :)

Show previous comments (3)
DevExpress Support Team 9 years ago

    To open the project, convert it to your current version using our Project Converter utility as described here:

    How to open Project Converter

    Let me know if you have additional questions regarding this subject.

      Thanks for example, show me that my project was almost ok :) problem was that i used View in sql and in that view cast float to numeric and do not change that in my object. So changing it back to float and all is ok . :)

      DevExpress Support Team 9 years ago

        I'm happy to hear that the issue is solved! Thank you for keeping us informed.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.