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

Column '?' does not belong to table

6 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George Catobus
Top achievements
Rank 1
George Catobus asked on 06 May 2009, 05:59 PM
I'm getting the following error when trying to aggregate an AutoGenerated column: Column 'UnitPrice' does not belong to table. I've created a very simple app to reproduce the problem. I need to know if I'm coding things in the wrong places, or if this is a problem with the grid itself.

ASPX Page

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<%

@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

 

<!

 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<

 

html xmlns="http://www.w3.org/1999/xhtml">

 

<

 

head runat="server">

 

 

<title></title>

 

</

 

head>

 

<

 

body>

 

 

<form id="form1" runat="server">

 

 

<asp:ScriptManager ID="aspScript" runat="server">

 

 

</asp:ScriptManager>

 

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

 

 

SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [UnitsInStock], [UnitPrice] FROM [Products]">

 

 

</asp:SqlDataSource>

 

 

<telerik:RadGrid ID="grdTemplate" runat="server" DataSourceID="SqlDataSource1"

 

 

AutoGenerateColumns="true" ShowGroupPanel="True" Skin="Office2007" Height="500" Width="100%"

 

 

OnColumnCreated="grdTemplate_ColumnCreated">

 

 

<ClientSettings AllowColumnsReorder="False" AllowDragToGroup="True">

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

 

 

</ClientSettings>

 

 

<MasterTableView AutoGenerateColumns="true" TableLayout="Fixed" ShowFooter="true" ShowGroupFooter="true" />

 

 

</telerik:RadGrid>

 

 

</form>

 

</

 

body>

 

</

 

html>

Code Behind

 

using

 

System;

 

 

 

using

 

System.Collections.Generic;

 

 

 

using

 

System.Web;

 

 

 

using

 

System.Web.UI;

 

 

 

using

 

System.Web.UI.WebControls;

 

 

 

using

 

Telerik.Web.UI;

 

 

 

public

 

partial class _Default : System.Web.UI.Page

 

{

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

// Add the expression

 

 

 

 

grdTemplate.MasterTableView.GroupByExpressions.Add(

GridGroupByExpression.Parse("SupplierID Group By SupplierID"));

 

}

 

protected void grdTemplate_ColumnCreated(object sender, GridColumnCreatedEventArgs e)

 

{

 

// Determine the column type

 

 

 

 

 

if (e.Column is GridBoundColumn && e.Column.UniqueName == "UnitPrice")

 

{

 

// Set the column aggreagate

 

 

 

 

(e.Column

as GridBoundColumn).Aggregate = GridAggregateFunction.Sum;

 

}

}

}

6 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 07 May 2009, 07:44 AM
Hi George,

Try setting the Aggregate property of the column in the PreRender event as shown below and see whether it it works.

CS:
 
 
protected void grdTemplate_PreRender(object sender, EventArgs e) 
    { 
 
        foreach (GridColumn col in grdTemplate.MasterTableView.RenderColumns) 
        { 
            if (col.UniqueName == "UnitPrice"
            { 
                GridBoundColumn boundCol = (GridBoundColumn)col; 
                boundCol.Aggregate = GridAggregateFunction.Sum; 
 
            } 
        } 
        grdTemplate.MasterTableView.Rebind(); 
    } 


Thanks
Shinu.
0
George Catobus
Top achievements
Rank 1
answered on 07 May 2009, 08:12 AM
Thank you very much for your help. That did the trick.
0
Gal
Top achievements
Rank 2
answered on 14 Aug 2014, 05:20 PM
I have the same Issue with a GridImageColumn Column using 

<telerik:GridImageColumn UniqueName="UpDownImage"  HeaderText="Trend" DataType="System.String"
                        DataImageUrlFormatString="~/Images/{0}.png" DataImageUrlFields="UpDown" DataAlternateTextField="UpDown"
                        ImageAlign="Middle" ImageHeight="16px" ImageWidth="16px" AllowFiltering="false">
                        ImageAlign="Middle" ImageHeight="16px" ImageWidth="16px" AllowFiltering="false" >
                        <HeaderStyle Width="20px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridImageColumn>

Issue was resolved by moving the ImageUrl update to the server side 

protected void RadGridReport_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataBoundItem = e.Item as GridDataItem;
 
        string UpDown = dataBoundItem["UpDown"].Text;
        ((System.Web.UI.WebControls.Image)dataBoundItem["UpDownImage"].Controls[0]).ImageUrl = "~/Images/"+UpDown+".png" ;
    }
}

0
Kostadin
Telerik team
answered on 19 Aug 2014, 10:35 AM
Hello Gal,

I prepared a small sample where I declare the image url on the mark-up and on my side the images are displayed properly. I attached the sample to this thread, so could you please give it a try and let me know how it differs from your real setup?

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gal
Top achievements
Rank 2
answered on 20 Aug 2014, 08:14 AM
HI Kostadin 

The problem is not displaying the Image (it is displayed properly) but when filtering/refreshing from code the grid the column causes the error message.
When I moved the code to  server side and the error stopped.
0
Kostadin
Telerik team
answered on 22 Aug 2014, 01:07 PM
Hi Gal,

I am afraid I was unable to replicate the issue in the previously attached sample. Could you please provide a small runnable example in order to investigate the cause for the issue which you are facing.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
George Catobus
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
George Catobus
Top achievements
Rank 1
Gal
Top achievements
Rank 2
Kostadin
Telerik team
Share this question
or