This is a migrated thread and some comments may be shown as answers.

RadGrid/DataReader Binding

1 Answer 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 29 Mar 2012, 11:47 PM
The RadGrid documentation (c.f. http://www.telerik.com/help/aspnet-ajax/grid-binding-to-datareader.html) explains that I need to close datareaders in the DataBound event.

However, if I create a SqlDataReader using ExecuteReader(CommandBehavior.CloseConnection), it appears that the RadGrid is smart enough to automatically close the SqlDataReader (and the corresponding connection). I suspect this because SqlDataReader.IsClosed returns True in the DataBound event.

Can you confirm my findings by pointing me to where this feature is documented?
If this feature is not documented, can you confirm that my findings are correct?
Failing that, will you please explain why I would need to close an already-closed datareader?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 04 Apr 2012, 08:48 AM
Hi Tom,

The CommandBehavior.CloseConnection closes the connection when the DataReader is closed as it is stated in the MSDN article below.

RadGrid does not automatically handle SqlConnection and SqlDataReader and we recommend using the approach described in the help article. Based on your scenario if the SqlDataReader is closed then the connection will automatically be closed too. Note that there is no need to close already close SqlDataReader.

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or