Ben's Random Mumbles

April 2003 - Posts

Passing SqlDataReader to Repeater OK?

I have made a post over at the asp.net forums about binding a SqlDataReader to a Repeater control but can't seem to get a straight answer. OK, I know I should be closing a DataReader when I'm finished with it, if I don't the connection doesn't get closed properly and after a while the web site will fall over.

But what about when you are binding a DataReader to a Repeater or DataList control? The DataReader is never closed, does the Repeater control handle this for me?

I have looked at 2 sample applications to see how they handle this, IBuySpyStore and the ASP.NET Forums. IBuySpy passes a SqlDataReader to the Repeater or DataList control, but the Forums read the data from the SqlDataReader into a collection of objects, close the DataReader and bind the collection to their control. Maybe I should be using the second technique, but I really like the simplicity of just binding a DataReader straight to a Repeater control.

Posted: Apr 01 2003, 07:48 PM by benricho | with 6 comment(s)
Filed under:
More Posts