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

Problem using HierarchyLoadMode Client

2 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
A
Top achievements
Rank 1
A asked on 16 Sep 2010, 03:58 AM
Hello,
I have a hierarchy grid with one nested level.
I'm having some issues with HierarchyLoadMode setting set to Client on my grid.
I load my grid on during Page_Load event, and it is loaded without any issues.
After that, the event to load the DetailTable is called:
protected void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
           GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
           string paramID = dataItem.GetDataKeyValue("Param_Id").ToString();
            string sConnectionString = "My Connection String";
  
            SQLDataSource1.SelectParameters["ModelIdParam"].DefaultValue = paramID ;
                SQLDataSource1.ConnectionString = sConnectionString;
                  
                e.DetailTableView.DataBind();
        }
I get an exception - +  ex {"Invalid attempt to call FieldCount when reader is closed."} 

I am not sure what I'm doing wrong, because if I don't set hierarchyModeLoad to Client, the exact same code runs without any issues, and I can expand/collapse the rows.

I would appreciate any help.

2 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 16 Sep 2010, 02:08 PM
Hello,

This exception is thrown when you try to either use a DataReader instance after it has already been closed or have one DataReader used by two controls.

Please note that as DataReader object can be read only forward, when iterated once you cannot read it again. Therefore, if you are using one DataReader to bind both the DetailTable and the MasterTableView, one solution to the problem could be to fill some kind of container object (datatable, custom object etc.) and bind the tableviews to it instead to the DataReader.

If this is not the case, you should make sure that you are not closing the DataReader too early. An appropriate place to close the DataReader and the connection is in the DataBound event handler of the RadGrid.

Regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vinit
Top achievements
Rank 1
answered on 04 Jun 2012, 02:22 PM

Hi ,
  I got an issue when I use Hierarchy load mode as 'client". when my hierarchical grid is in ASPX page with client load mode, It work fine.
Expand collapse works fine.But when I put the same code in the user control , then with "client" hierarchy load mode expand column does not work. We just can't see the detail table.

If I change the load mode to the serverOnDemand / serverbind It works .

I have attached the file.

Please guide me , not able to understand why this is happening.

Regards
Vinit

Tags
Grid
Asked by
A
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Vinit
Top achievements
Rank 1
Share this question
or