Error when binding repeater control with IDataReader after converting asp.net 3.5 to 4.0

Topics: Data Access Application Block
Sep 17, 2011 at 12:07 AM
Hi,

I am trying to migrate asp.net 3.5(enterprise library 4.1) working application to asp.net 4.0 (enterprise library 5.0) version.

My Application (asp.net 3.5) is working without any issues on production, after migrating to asp.net 4.0 getting the below error

"An invalid data source is being used for rptStudents. A valid data source must implement either IListSource or IEnumerable."

Note: Migrated to Enterprise library 5.0 from 4.1

Code:

Using drStudents As IDataReader = dbStudents.ExecuteReader(cmdStudents)
With rptStudents
.DataSource = drStudents //gettting an error, rptStudents is a repeater control
.DataBind()
End With
End Using
----------------------------------------------------------------------------------------------------------
Thanks in advance
Sep 19, 2011 at 4:38 AM

Hi,

It seems like you are not binding to the correct data type. Is drStudents a SqlDataReader? Try storing first the data that you get from drStudents in a container that implements IListSource or IEnumerable, such as List<T>. Then, try passing in that container as the data source of rptStudents.

My two cents. :-)

Sep 19, 2011 at 5:18 PM

Hi CodeTrainer,

Thanks for your response.

drStudents is a IDataReader type and this code is working good in production with Enterprise library 3.5, I am getting the error after upgraded to Enterprise library 5.0 without any code changes.

I searched online for a solution but every post suggests code changes.

Please advise me how to make it work without any code changes.

Sep 20, 2011 at 3:27 AM

Hi,

Sorry but I do not know of any other way to proceed without code changes.

Sep 22, 2011 at 11:58 AM

Unfortunately, modifying your code is the only option you may have since some Entlib code has been refactored on version 5.0.

 

Noel Angelo Bolasoc
Avanade Software
Avanade, Inc.
Contact Us