Cannot find a cell bound to column name

7 posts, 0 answers
  1. hamda
    hamda avatar
    20 posts
    Member since:
    Apr 2010

    Posted 31 Aug 2010 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 31 Aug 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. hamda
    hamda avatar
    20 posts
    Member since:
    Apr 2010

    Posted 31 Aug 2010 Link to this post

    Hey there,

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

    Hamda
  5. Gaurav
    Gaurav avatar
    6 posts
    Member since:
    Feb 2013

    Posted 04 Mar 2013 Link to this post

    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




  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2013 Link to this post

    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.
  7. Harendra
    Harendra  avatar
    9 posts
    Member since:
    Jun 2013

    Posted 15 Jul 2013 Link to this post


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

    Thanks a lot..!!
  8. Sk
    Sk avatar
    9 posts
    Member since:
    May 2013

    Posted 09 May Link to this post

    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.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017