I have a function that is normally called while looping inside a SqlDataReader, that will take data from that SqlDataReader and do some stuff with it.
Now, I need to be able to also call it from inside a Data Bound Repeater object, that is also bound to a SqlDataReader...
In the DataBound control, in the "OnDataBinding" event, I normally do this, when binding to a DataSet:
RepeaterItem Binder = (RepeaterItem) Me.NamingContainer;
DataRowView rowResult = (DataRowView) Binder.DataItem;
Now, since I'm binding to a DataReader, I tried:
SqlDataReader rowResult = (SqlDataReader) Binder.DataItem;
And it doesn't work because apparently the DataItem is of type DataRecordInternal
I WAS able to cast it to a "DbDataRecord", and I can access its values, but I obviously can't pass it as a parameter to the function that expects a SqlDataReader...
I also can't find any base class or interface they both have in common, to use for the parameter...
What's puzzling me the most here is how, through the Data Binding, the SqlDataReader gets "turned into" a DbDataRecord. If I could do that inside my function, I could have 2 overloads: One that takes a DbDataRecord and does its job, and one that takes a SqlDataReader, "converts it" into a DbDataRecord, and calls the first overload.
Any ideas?
Thanks!