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

Cannot find a cell bound to column name

6 Answers 1992 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hamda
Top achievements
Rank 1
hamda asked on 31 Aug 2010, 06:31 AM
Hi all,

I'm getting this error when loading my grid. I'm using ItemDataBound to replace numbers in the grid with names. what could be the problem.

Thanks,

Hamda

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Aug 2010, 07:23 AM
Hello,


From the error, it is clear that there is no column/cell with the name that you used in code. This can happen if you are trying to access a cell, with the wrong name. Please check whether you typed the name correctly.

Are you using hierarchy? If yes, keep in mind that the ItemDataBound event will be raised for all items in the master and the detail table, when they are populated. Therefore, you will need to differentiate between the different items. Also, you can debug to see whether the error is thrown for master table item, or for a detail table one.


-Shinu.
0
hamda
Top achievements
Rank 1
answered on 31 Aug 2010, 09:21 AM
Hey there,

Thanks I fixed it by checking the naming thing i got some names wrong.
Thanks anyway.

Hamda
0
Gaurav
Top achievements
Rank 1
answered on 04 Mar 2013, 01:38 PM
Friends please do help me. I have a RadGrid in my page and I am struggling with a few issues in accessing the GridDataItems. I am also receiving the error "Cannot find a cell bound to column name". My aspx is as follows:

<Telerik:RadGrid ID="rgdActiveBatchJobs" runat="server" AutoGenerateColumns="false"

                                    AllowAutomaticInserts="false" AllowMultiRowSelection="true" OnItemCreated="rgdActiveBatchJobs_ItemCreated"

                                     ShowGroupPanel="True" GridLines="none">

                                    <PagerStyle Mode="NumericPages"></PagerStyle>

                                    <MasterTableView AutoGenerateColumns="False" GroupLoadMode="Client" GroupsDefaultExpanded="false" >

                                        <GroupByExpressions>

                                            <Telerik:GridGroupByExpression>

                                                <SelectFields>

                                                    <Telerik:GridGroupByField FieldAlias="Plan" FieldName="Plan"></Telerik:GridGroupByField>

                                                </SelectFields>

                                                <GroupByFields>

                                                    <Telerik:GridGroupByField FieldName="Plan"></Telerik:GridGroupByField>

                                                </GroupByFields>

                                            </Telerik:GridGroupByExpression>

                                        </GroupByExpressions>

                                        <Columns>

                                            <Telerik:GridBoundColumn HeaderText="Active Batch Jobs" DataField="Job Name" ReadOnly="true"

                                                Visible="true" UniqueName="Job Name">

                                            </Telerik:GridBoundColumn>

                                            <Telerik:GridClientSelectColumn HeaderText="Trigger" DataTextField="Trigger" UniqueName="Trigger">

                                            </Telerik:GridClientSelectColumn>

                                            <Telerik:GridTemplateColumn HeaderText="Status">

                                                <ItemTemplate>

                                                    <asp:Image ID="ActiceBatchJobImageCol" runat="server" ImageUrl="" AlternateText="Not Yet started to Promote" />

                                                </ItemTemplate>

                                            </Telerik:GridTemplateColumn>

                                        </Columns>

                                    </MasterTableView>

                                    <ClientSettings EnableRowHoverStyle="false" AllowGroupExpandCollapse="True">

                                        <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true"></Selecting>

                                    </ClientSettings>

                                    <GroupingSettings ShowUnGroupButton="true"></GroupingSettings>

                                </Telerik:RadGrid>


As can be seen from above I have used grouping based on a field called "Plan" in the above grid. Now from server side when I wish to access grid rows based on the plan name and the column "Job Name" I am struggling a bit. 

    rgdActiveBatchJobs.DataSource = dt;
            rgdActiveBatchJobs.DataBind();

            foreach (GridDataItem item in rgdActiveBatchJobs.MasterTableView.Items)
            {                
string jobName = item["Job Name"].Text;
string planName = item["Plan"].Text;
    }

in the above code the jobname is coming out fine but when it runs the line string planName = item["Plan"].Text;  it throws an error "Cannot find a cell bound to column name 'Plan'"  Could anyone please reply how to obtain the value of the group by field for each datarow of the radgrid. 

Thanks and Regards,
Gaurav Agrawal




0
Shinu
Top achievements
Rank 2
answered on 05 Mar 2013, 05:58 AM
Hi,

Please try the following code snippet to get the text in GroupByField.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridGroupHeaderItem)
    {
        GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
        DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
        item.DataCell.Text = groupDataRow.Row.ItemArray[0].ToString();
    }
}

Thanks,
Shinu.
0
Harendra
Top achievements
Rank 1
answered on 15 Jul 2013, 05:19 AM

Thank you very much. It helped me to solve my problem.

Thanks a lot..!!
0
Sk
Top achievements
Rank 1
answered on 09 May 2016, 03:37 PM

Hi,

Please help me to sort out this issue :

On rad grid Item Data bound when i am trying to check for null it throw exception.

if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
                {
                    GridDataItem dataBoundItem = e.Item as GridDataItem;

                    if (dataBoundItem["Payment Status"] != null)
                    {
                        hlControl.Text = e.Item.Cells[grdACHStatus.MasterTableView.GetColumn("Payment Status").OrderIndex].Text;
                        hlControl.ForeColor = System.Drawing.Color.Blue;
                        hlControl.Style.Add("text-decoration", "underline");
                        hlControl.Style.Add("cursor", "pointer");

                  }

             }

If i use below code it always count this as null:

GridColumn col = grdACHStatus.MasterTableView.Columns.FindByUniqueNameSafe("Payment Status");
if (col != null)
   {

}

Please suggest.

Tags
Grid
Asked by
hamda
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
hamda
Top achievements
Rank 1
Gaurav
Top achievements
Rank 1
Harendra
Top achievements
Rank 1
Sk
Top achievements
Rank 1
Share this question
or