We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose cells webgrid binding issues

I had an issue binding an aspose.cells.webgrid to a collection of a linq objects yesterday. I was using auto-generated columns, and I found that the columns that it left out in the grid were those columns where the property was nullable. Is this a known issue?

In the ASPOSE sample demo project I modified the example in databind3 so that the DateTime “DateField1” field in the MyCustomClass was instead DateTime?, i.e. nullable After doing this DateField1 was dropped from the grid. Same problem as I was having above.

@phillipsjm,

Thanks for your query.

Well, Aspose.Cells.GridWeb might not work properly regarding bind with linq objects but it works fine when binding with customized collection object. So, I think you should modify your code
accordingly, see the document for your reference:
https://docs.aspose.com/display/cellsnet/Binding+Worksheet+to+a+Customized+Collection+Object+using+GridWeb

Thank you.

Look at the second part where I say I modified the MyCustomClass in the ASPOSE sample demo project that you guys built. Basically I changed the property of the DateField1 from DateTime to DateTime?. After making this change the grid failed to load the DateField1 property. I’m hoping this can be fixed as I don’t see any problems with the aspose.cells.webgrid loading Excel files that may contain null decimal data. Seems a bit of a shortfall not being able to do this as Linq is an adopted standard for pulling data through an object model rather than using ADO etc to hit the database.

The link you sent is the same code that I modified. Take that code in the link, change the DateField1 to be of type DateTime?, and then run the code. Does the DateField1 column now get dropped in the grid?

@phillipsjm,

I am not sure what you have changed to the sample code pasted in the document. The underlying field is already of DateTime type. Moreover, I tested the sample code in the document/article, it works fine.

Could you provide us a sample project (runnable) to show the issue, you may modify the existing code in the document, we will check it soon. You may zip the project and share it via dropbox or Google drive.

Thank you.

There is a data type called DateTime that allows you to store dates in C#. There has to be a date in this field.

There is also the datatype DateTime?, which means I can store dates and nulls within the property in C#. These are often referred as nullable types. This is the equivalent of a SQL Server DateTime field that allows nulls.

In the myCustomRecord class example that ASPOSE uses to show how you can bind to custom classes (which is what I am doing using Linq to SQL), I simply changed the datatype on the DateField1 from DateTime to DateTime?
Then this field failed to display in the web grid. Please make the changes I made below and try this out in the demo app for ASPOSE.

This is a common real life situation where for decimal and datetime fields, its typical that the field could be empty.

Is there a resolution for this issue yet?

@phillipsjm,

We appreciate if could create a simple sample project (runnable), zip the project to reproduce the issue on our end with all the details. You may modify the existing code in the document, zip the project and share it via dropbox or Google drive, we will check it soon.