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

Hierarchical DetailTableDataBind with DataTables Cannot find parent item column

1 Answer 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leslie
Top achievements
Rank 1
Leslie asked on 20 Jun 2012, 04:17 AM
Hi, I am trying to bind to a hierarchical grid using DetailTableDataBind with DataTable.Select as described here.

GridDataItem parentItem = (GridDataItem)e.DetailTableView.ParentItem;
DataTable dt = (DataTable)e.DetailTableView.DataSource;
e.DetailTableView.DataSource = dt.Select("BQRef == '" + parentItem["BQRef"].Text + "'");

But upon binding, I've received an error, stating "Cannot find a cell bound to column name 'BQRef'". Any ideas? Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 20 Jun 2012, 06:16 AM
Hello,

I am not able to generate this issue please check below code snippet.
  <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
            OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource"
>
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="Name">
 
                <Columns>
                    <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                    </telerik:GridBoundColumn>
                </Columns>
                <DetailTables>
                    <telerik:GridTableView>
                        <Columns>
                            <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
            </MasterTableView>
        </telerik:RadGrid>

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        dynamic data = new[] {
                new { ID = 1, Name ="Name1"},
                new { ID = 2, Name = "Name2"},
                new { ID = 3, Name = "Name3"},
                new { ID = 4, Name = "Name4"},
                new { ID = 5, Name = "Name5"}
            };
        RadGrid1.DataSource = data;
    }
protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        GridDataItem item = e.DetailTableView.ParentItem as GridDataItem;
        string strcolumn = item["Name"].Text;
        string strkey = item.GetDataKeyValue("Name").ToString();
 
        dynamic data = new[] {
                new { ID = 1, Name ="Name_1"}
            };
        e.DetailTableView.DataSource = data;
    }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Leslie
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or