Column '?' does not belong to table

7 posts, 1 answers
  1. George Catobus
    George Catobus avatar
    8 posts
    Member since:
    Dec 2007

    Posted 06 May 2009 Link to this post

    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;

     

    }

    }

    }

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 May 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. George Catobus
    George Catobus avatar
    8 posts
    Member since:
    Dec 2007

    Posted 07 May 2009 Link to this post

    Thank you very much for your help. That did the trick.
  5. Gal
    Gal avatar
    48 posts
    Member since:
    Apr 2009

    Posted 14 Aug 2014 Link to this post

    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" ;
        }
    }

  6. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 19 Aug 2014 Link to this post

    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.

     
  7. Gal
    Gal avatar
    48 posts
    Member since:
    Apr 2009

    Posted 20 Aug 2014 in reply to Kostadin Link to this post

    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.
  8. Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 22 Aug 2014 Link to this post

    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.

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