The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
My issue is a little confusing, but I''ll try my best to explain it.
I have two classes, clsItem and clsTotalItem. The later inherits the former.
Basically, clsTotalItem overrides a number of the properties of it''s base class, providing totals information for a collection of clsItem classes.
I am adding instances of these object to an arraylist and then binding that arraylist to the grid control. The idea being that total''s rows appear in the grid below items.
Sorting is done via a customised comparer attached to the arraylist. The grid has nothing to do with it.
This all works fine - half of the time.
If the arraylist is sorted so that one of the clsItem objects is ''first'', then the grid populates fine. The clsTotalItem objects drop into place nicely. However, if the grid is sorted so that the first item is a clsTotalItem object, then the grid falls over with a message along the lines of ''object not of expected type'' (something like that, I''m writing this from home and don''t have the problem in front of me).
I''m ''guessing'' that internally the grid is looking at the type of object in the first row of the data source and storing it somewhere. I assume that it is then casting the other rows into that type. This makes sense that it works fine if the first object was a clsItem... as clsTotalItem can be cast into clsItem fine. However, it makes sense that it will not work the other way because clsItem cannot be cast into clsTotalItem.
Any suggestions how to work around this? I guess that I need a way to force the grid to always assume that the class is clsItem, regardless of what the first row is.
If any of this is unclear, please ask for clarification.
Thanks in advance, I look forward to hearing from you.
Damien
ADAdministrator Syncfusion Team April 5, 2004 08:25 AM UTC
One way to handle this is to have your arraylist be strongly typed by implementing ITypedList. There are some snippets in http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9194. There is a sample project in this thread. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11215