e.item.DataItem causes invalid cast exception
I kept getting an exception when attempting to cast e.Item.DataItem to DataRowView in a repeater control ItemDataBound event.
Issue was I was binding a DataReader, which requires DBDataRecord in System.Data.Common. Dataset uses DataRowView.
If the data source is a DataReader object, you must cast e.Item.DataItem as type DBDataRecord (from System.Data.Common) in the event handler. If the data source is a DataTable, you must cast e.Item.DataItem as type DataRowView.
Trackback URI |