A
A Traveler
Hi,
I have a custom collection class i wrote, LineItemsCollection, which is a
strongly typed collection of objects of my LineItem class.
The LineItem class is a simple class with just a couple properties, ProdID,
Description, Quantity and UPC. 3 strings and a long.
The LineItemsCollection class inherits from
System.Collections.Specialized.NameObjectCollectionBase.
It also implements both IEnumerable and IList.
I can bind a DataGrid to my collection with no problem. In the
ItemCreated/ItemDataBound, the value of e.Item.DataItem is properly returned
as a LineItem object. So i can do <%#
DataBinder.Eval(Container,"DataItem.Quantity") %> and get back a quantity.
However, if i try to bind to a Repeater, and i do the same thing, i get an
error "DataBinder.Eval: 'System.String' does not contain a property with the
name Quantity." I had had this problem with the datagrid when i first made
my collection. After researching, i found out to inherit from IList, and it
fixed it. But apparently the Repeater does its databinding differently than
the DataGrid?
Can anyone explain what the Repeater needs differently than the Datagrid in
order to bind to a custom collection??
Thanks in advance,
- Arthur Dent.
I have a custom collection class i wrote, LineItemsCollection, which is a
strongly typed collection of objects of my LineItem class.
The LineItem class is a simple class with just a couple properties, ProdID,
Description, Quantity and UPC. 3 strings and a long.
The LineItemsCollection class inherits from
System.Collections.Specialized.NameObjectCollectionBase.
It also implements both IEnumerable and IList.
I can bind a DataGrid to my collection with no problem. In the
ItemCreated/ItemDataBound, the value of e.Item.DataItem is properly returned
as a LineItem object. So i can do <%#
DataBinder.Eval(Container,"DataItem.Quantity") %> and get back a quantity.
However, if i try to bind to a Repeater, and i do the same thing, i get an
error "DataBinder.Eval: 'System.String' does not contain a property with the
name Quantity." I had had this problem with the datagrid when i first made
my collection. After researching, i found out to inherit from IList, and it
fixed it. But apparently the Repeater does its databinding differently than
the DataGrid?
Can anyone explain what the Repeater needs differently than the Datagrid in
order to bind to a custom collection??
Thanks in advance,
- Arthur Dent.