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

[Solved] Problem in Hierarchical RadGrid Export To Excel

5 Answers 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thunaivan
Top achievements
Rank 1
Thunaivan asked on 30 Jun 2009, 06:43 AM

This Error "Cannot find a cell bound to column name 'goalname' " arises only when i insert "grdGoals.MasterTableView.HierarchyDefaultExpanded = true;" this statement in codebehind on click of Export to Excel.
Code:

 <telerik:RadGrid>   
 <MasterTableView Width="100%" Name="Master" HierarchyLoadMode="ServerBind" DataKeyNames="InvoiceId"   
HorizontalAlign="NotSet" CommandItemDisplay="Top">   
 <DetailTables>   
<telerik:GridTableView Name="Detail" BackColor="White" AllowNaturalSort="true" runat="server"   
DataKeyNames="invoiceidfkid" Width="100%">   
<ParentTableRelation>   
<telerik:GridRelationFields MasterKeyField="InvoiceId" DetailKeyField="invoiceidfkid">   
</telerik:GridRelationFields>   
</ParentTableRelation>   
<Columns>   
 <telerik:GridBoundColumn HeaderText="invoiceidfkid" DataField="invoiceidfkid" Display="false"   
SortExpression="invoiceidfkid" UniqueName="invoiceidfkid">   
</telerik:GridBoundColumn>   
</Columns>   
</telerik:GridTableView>   
</DetailTables>   
<Columns>   
<telerik:GridBoundColumn HeaderText="InvoiceId" Display="false" DataField="InvoiceId" SortExpression="InvoiceId"   
UniqueName="InvoiceId">   
<ItemStyle Width="0%" />   
<HeaderStyle ForeColor="Black" HorizontalAlign="Center" />   
</telerik:GridBoundColumn>   
</MasterTableView>   
 </telerik:RadGrid>  

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jun 2009, 07:07 AM
Hello,

Anywhere in your code are you trying to access a column (in code-behind) using the GetColumn server-side method? If so you would have to differentiate between the mastertable and the detailtable before accessing a column from respective tableviews. You can use the Name Property of the GridTableViews to differentiate between the tables. Check out the example below:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach(GridItem item in RadGrid1.Items) 
        { 
            if (item.OwnerTableView.Name == "Master") 
            { 
                GridColumn col = RadGrid1.MasterTableView.GetColumn("goalname"); 
            } 
        }         
    } 
or
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Master"
        { 
            GridDataItem editItem = (GridDataItem)e.Item;             
            string strtxt = editItem["goalname"].Text; 
        } 
    } 
Check for the ownertableviews where ever you try to access a column("goalname" in your case).

Hope this helps...
Princy.
0
Thunaivan
Top achievements
Rank 1
answered on 30 Jun 2009, 07:37 AM
protected void rgInvoice_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)  
    {  
        InvoicePresenter objInvoicePresenter;  
        try 
        {  
 
            objInvoicePresenter = new InvoicePresenter(this);  
            vInvoicePkId = e.DetailTableView.ParentItem["golename"].Text;  
            e.DetailTableView.DataSource = objInvoicePresenter.getInvoiceProjectDetails();  
        }  
        catch (Exception ex)  
        {  
            log.Error(ex.Message, ex);  
        }  
        finally 
        {  
            objInvoicePresenter = null;  
        }  
    } 
 I cheked out, as you suggested. rgInvoice_DetailTableDataBind() is the only method having "goalname" in code behind. Can you please help me to modify the code.
0
Thunaivan
Top achievements
Rank 1
answered on 30 Jun 2009, 10:09 AM
any suggestion are welcomed.
0
Thunaivan
Top achievements
Rank 1
answered on 30 Jun 2009, 11:00 AM
Server Error in '/Geavista' Application.  
--------------------------------------------------------------------------------  
 
Cannot find a cell bound to column name 'goalname'   
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
 
Exception Details: Telerik.Web.UI.GridException: Cannot find a cell bound to column name 'goalname'  
 
Source Error:   
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
 
Stack Trace:   
 
 
[GridException: Cannot find a cell bound to column name 'goalname']  
   Telerik.Web.UI.GridDataItem.get_Item(String columnUniqueName) +345  
   Telerik.Web.UI.Grid.Export.TableViewExporter.ApplyExcelCellFormating(GridItem item) +177  
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareTableItemsVisibility(GridItem item, Boolean isExcelExport) +416  
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareTableItemsVisibility(GridItem item, Boolean isExcelExport) +308  
   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +341  
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98  
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20  
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59  
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68  
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121  
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37  
   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderPage(HtmlTextWriter nullWriter, Control page) +133  
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98  
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20  
   System.Web.UI.Page.Render(HtmlTextWriter writer) +26  
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558  
 
   
 
0
Pavlina
Telerik team
answered on 30 Jun 2009, 11:50 AM
Hi Thunaivan,

I am afraid that the provided information is not enough to determine what have caused the unexpected behavior. At this point I will ask you to send us the whole problematic page, so we can check it.
Additionally, could you please confirm that you have parent item with name "goalname" in MasterTableView?

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Thunaivan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Thunaivan
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or