How determine type of DataItem in custom control??

A

A Traveler

Hello, i have a control inheriting from the DataRepeater control. It has a
property which is the name of a Column/Property to run subtotals on from the
datasource; this is stored in pSumColumn As String. I have an OnItemCreated
handler.

Now, in my project, i have a LineItemsCollection class which is a
strongly-typed collection of LineItem objects. The LineItemsCollection class
inherits from
System.Collections.Specialized.NameObjectCollectionBase, and implements
IEnumerator and IList.

In my ItemCreated handler, when i try to do DataBinder.Eval(e.Item.DataItem,
pSortColumn) it tells me that "System.String" does not have a property
"Quantity" (assuming pSumColumn = "Quantity"). I dont understand why it is
trying to access e.Item.DataItem as a string, instead of as the type of
object it really is (in this case, a LineItem). The value it is pulling for
the String of it though is actually the value of one of the other properties
of the LineItem class.

I had problems like this when first doing my collection class and trying to
bind a datagrid to it, i couldnt access item properties. But this was fixed
after implementing, as id read, the IList interface.

How can i get e.Item.DataItem to reflect the proper object type???

Thanks in advance.
- Arthur Dent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top