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 :)
Hello,
I've created a sample project based on your description. In it, I used the Order Details data table from the Northwind data base.
The project works correctly on my side. I've created a sample video to demonstrate that. Would you please modify the project if I'm missing something? It will allow me to find a precise solution for you.
hello, i cant open your example i get dozens of error "The type do not exist" . I have VS 2012, dx 1.5.7.
sorry , canno run not open :) i can open it but cant run.
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 . :)
I'm happy to hear that the issue is solved! Thank you for keeping us informed.