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

Dynamic Docks, ASCXs with RadGrids and IDataReaders: A Nightmare on .NET Street :)

1 Answer 94 Views
Dock
This is a migrated thread and some comments may be shown as answers.
NMA
Top achievements
Rank 1
NMA asked on 30 Jan 2009, 04:02 PM
I was able to create and add RadDocks dynamically to my RadZones. Contents of these dynamically created RadDocks are loaded from ascx files. Those ascx files contain RadGrids in them. I prefer using IDataReader's for the datasources of these RadGrids. However, once everything is rendered, I click "refresh" on a RadGrid and I receive the following error:

System.InvalidOperationException: Invalid attempt to FieldCount when reader is closed.

I get the same error when I click on delete icon for any row of the RadGrids...

I found out that this problem is caused by the fact that the IDataReader, the datasource, is closed once the DataBound event is completed. 

I assign this IDataReader object to the DataSource field of the RadGrid in OnNeedDataSource event. I also created event methods for both DataBinding and DataBound and put some breakpoints to see what the problem is. I saw that once I click on "refresh" on a RadGrid, NeedDataSource, DataBinding and DataBound event methods were called respectively, however, strangely enough, another visit to DataBinding event method is performed (I don't know the source or the reason). This time, the system throws the error I described above because the DataReader is already closed after DataBound event...

What can be the reason for this?

Note: If I use DataTables instead of IDataReaders, everything works fine as expected ;)

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Petio Petkov
Telerik team
answered on 03 Feb 2009, 01:13 PM
Hi NMA,

Unfortunately the provided information is not enough to find where the problem comes from. Please open a new support ticket and send us a running project, where we can observe the problems you have. Once we receive it we will do our best to help you.

All the best,
Petio Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Dock
Asked by
NMA
Top achievements
Rank 1
Answers by
Petio Petkov
Telerik team
Share this question
or