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

[Solved] GridCalculatedColumn Cannot find column error

5 Answers 585 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Genocide
Top achievements
Rank 2
Genocide asked on 05 Mar 2010, 06:29 AM
I get the error "Cannot find column [their_qty]" when I added a GridCalculatedColumn to my grid.

Here is the stack trace shown:
 
[EvaluateException: Cannot find column [their_qty].]  
   System.Data.NameNode.Bind(DataTable table, List`1 list) +1188205  
   System.Data.DataExpression.Bind(DataTable table) +59  
   System.Data.DataColumn.SetTable(DataTable table) +4828348  
   System.Data.DataColumnCollection.BaseAdd(DataColumn column) +272  
   System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column) +78  
   System.Data.DataColumnCollection.Add(DataColumn column) +8  
   Telerik.Web.UI.GridDataTableFromEnumerable.GetColumnsToUse() +2004  
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +1028  
   Telerik.Web.UI.GridResolveEnumerable.Initialize() +55  
   Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +40  
   Telerik.Web.UI.GridResolveEnumerable.get_DataTable() +31  
   Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +222  
   Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +155  
   Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +556  
   Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +219  
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +73  
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57  
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114  
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31  
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142  
   Telerik.Web.UI.GridTableView.PerformSelect() +28  
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73  
   Telerik.Web.UI.GridTableView.DataBind() +354  
   Telerik.Web.UI.RadGrid.DataBind() +165  
   Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +3855  
   Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +175  
   System.Web.UI.Control.LoadRecursive() +50  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Control.LoadRecursive() +141  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627  
   

If I can use a GridNumericColumn for the same data field without a problem, but the presence of this particular column in a calculation is objectionable.

Here is an extract of the RadGrid declaration:
      <telerik:RadGrid ID="rgrdReport" runat="server" GridLines="Vertical" Skin="Office2007" 
        AutoGenerateColumns="False" PageSize="25" EnableLinqExpressions="false">  
        <MasterTableView CommandItemSettings-ShowExportToWordButton="True" CommandItemSettings-ShowExportToPdfButton="True" 
          CommandItemSettings-ShowExportToExcelButton="True">  
          <CommandItemSettings ShowExportToExcelButton="True"   
            ShowExportToPdfButton="True" ShowExportToWordButton="True" /> 
          <Columns> 
            <telerik:GridNumericColumn UniqueName="column" HeaderText="Our Quantity" DataField="our_qty" DataFormatString="{0:N}" DataType="System.Decimal">  
                  <ItemStyle Width="80px" HorizontalAlign="Right" /> 
            </telerik:GridNumericColumn> 
            <telerik:GridNumericColumn UniqueName="column1" HeaderText="Our $" DataField="our_amount" DataFormatString="{0:C}" DataType="System.Decimal">  
                  <ItemStyle Width="80px" HorizontalAlign="Right" /> 
            </telerik:GridNumericColumn> 
            <telerik:GridNumericColumn UniqueName="column2" HeaderText="Their Quantity" DataField="their_qty" DataFormatString="{0:N}" DataType="System.Decimal">  
                  <ItemStyle Width="80px" HorizontalAlign="Right" /> 
            </telerik:GridNumericColumn> 
            <telerik:GridNumericColumn UniqueName="column3" HeaderText="Their $" DataField="their_amount" DataFormatString="{0:C}" DataType="System.Decimal">  
                  <ItemStyle Width="80px" HorizontalAlign="Right" /> 
            </telerik:GridNumericColumn> 
            <telerik:GridCalculatedColumn UniqueName="column4" HeaderText="Quantity Variance" DataFields="our_qty, their_qty" Expression="{1}-{0}">  
                  <ItemStyle Width="80px" HorizontalAlign="Right" /> 
            </telerik:GridCalculatedColumn> 
            <telerik:GridCalculatedColumn UniqueName="column5" HeaderText="$ Variance" DataFields="our_amount, their_amount" Expression="{1}-{0}">  
                  <ItemStyle Width="80px" HorizontalAlign="Right" /> 
            </telerik:GridCalculatedColumn> 
          </Columns> 
        </MasterTableView> 
        <ClientSettings AllowDragToGroup="False">  
          <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
        </ClientSettings> 
      </telerik:RadGrid> 
 

Remove "column4" and the grid displays fine.  How can [their_qty] be ok in column2 but not column4?
This is the second error I received with this grid, but a search of the forum and adding EnableLinqExpressions="false" to the defenition fixed the earlier error "DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'column4Result'."

Thanks.

5 Answers, 1 is accepted

Sort by
0
Joel R
Top achievements
Rank 1
answered on 06 Mar 2010, 07:45 PM
Are you using version 2009.2.826.35 of the controls or higher.  I had a similar problem which I adjusted due to the version change to be like what you have and it works now.
0
Genocide
Top achievements
Rank 2
answered on 08 Mar 2010, 10:55 PM

Sorry, forgot the version number, 2009.3.1314.35.  So yes, newer version.

 

0
Tsvetoslav
Telerik team
answered on 12 Mar 2010, 06:42 AM
Hi Drew,

Could you show how you are binding the grid? Could you paste your whole aspx and code-behind.

Thanks.

Regards,
Tsvetoslav
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
Genocide
Top achievements
Rank 2
answered on 12 Mar 2010, 07:04 AM
Sorry, can't give you everything (in a public place), but here's the important details:
        protected void Page_Load(object sender, EventArgs e)  
        {  
            // Prepare data connection  
            da.Initialise();  
 
            if (!Page.IsPostBack)  
            {  
                _JobID = Convert.ToInt32(Request.QueryString["J"]);  
                PopulateGrid();  
            }  
            else 
            {  
                JobID = Convert.ToInt32(ViewState["JID"]);  
            }  
        }  
 
       // Function from Page code behind  
       private void PopulateGrid()     
        {     
            Oracle.DataAccess.Client.OracleDataReader drReport = null;     
    
            // Get data     
            try    
            {     
                da.GetReport(JobID, ref drReport);     
    
                rgrdReport.DataSource = drReport;     
                rgrdReport.DataBind();     
    
                drReport.Close();     
                drReport.Dispose();     
            }     
            catch (Exception ex)     
            {     
                System.Diagnostics.Debug.WriteLine(ex.Message);     
            }     
        }     
   
        // This function from custome data access class  
        public void GetReport(int JobID, ref Oracle.DataAccess.Client.OracleDataReader drDetails)     
        {     
            Oracle.DataAccess.Client.OracleCommand dbCom = NewCommand("fetch_report");     
            dbCom.Parameters.Add(NewParameter("i_job_id", OracleDbType.Decimal, JobID));     
            dbCom.Parameters.Add(NewParameter("o_rtp", OracleDbType.RefCursor, null));     
    
            /// TODO: Query exception handling     
            dbCom.ExecuteNonQuery();     
    
            drDetails = ((Oracle.DataAccess.Types.OracleRefCursor)dbCom.Parameters["o_rtp"].Value).GetDataReader();     
        }     
 
There are no events bound to the grid so nothing to include.
Only NewCommand() and NewParameter() are missing, which are just to shorthand to repeated data tasks.
0
Tsvetoslav
Telerik team
answered on 15 Mar 2010, 03:11 PM
Hi Drew,

Try using Advanced databinding for your RadGrid control as opposed to Simple databinding

Regards,
Tsvetoslav
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.
Tags
Grid
Asked by
Genocide
Top achievements
Rank 2
Answers by
Joel R
Top achievements
Rank 1
Genocide
Top achievements
Rank 2
Tsvetoslav
Telerik team
Share this question
or