


Hi,
I have a grid where I am dynamically creating all of my columns because I do not know the columns that will be returned at design time. I also want to add a Total column at the end that is going to summarize the particular month range the user has selected. My column is created correctly if I hardcode the months (see commented line below); however, if I try to build a similar string and pass that in the datafields, I get the error "Telerik.Web.UI.GridException: DataField "JAN10","FEB10","MAR10","APR10","MAY10","JUN10" for GridCalculatedColumn "Total" does not exist in current DataSource.". You can see from the error message that my string is in the correct format. I have seen posts on the forum regarding similar issues and it said that it was fixed in the latest release, but mine is still failing. I am using 10.2.
Thanks,
Tami
private void CreateCalcColumn(GridTableView oTableView, string sMonths) { GridCalculatedColumn totalColumn; totalColumn = new GridCalculatedColumn(); oTableView.Columns.Add(totalColumn); totalColumn.UniqueName = "Total"; totalColumn.Expression = "{0}+{1}"; totalColumn.DataType = typeof(double); totalColumn.DataFields = new string[] { lstMonths }; //totalColumn.DataFields = new string[] { "JAN10", "FEB10" }; totalColumn.Aggregate = Telerik.Web.UI.GridAggregateFunction.Sum; totalColumn.HeaderText = "Total"; totalColumn.HeaderStyle.CssClass = "gridheader"; }<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FayezTest.aspx.cs" Inherits="Utilities_FayezTest" %><%@ 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="script1" runat="server"> </asp:ScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="WorkClassificationValue"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="WorkClassificationValue" /> <telerik:AjaxUpdatedControl ControlID="EmployeeValue" /> <telerik:AjaxUpdatedControl ControlID="SitesValue" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="EmployeeValue"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="EmployeeValue" /> <telerik:AjaxUpdatedControl ControlID="Test" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <div> <telerik:RadComboBox ID="WorkClassificationValue" runat="server" CssClass="DatabaseFieldName" AutoPostBack="true" Width="100%" AllowCustomText="true"> <CollapseAnimation Duration="200" Type="OutQuint" /> <ExpandAnimation Type="OutQuart" /> </telerik:RadComboBox> <asp:Panel ID="EmployeeSection" runat="server" Visible="false"> <table class="DatabaseField" id="Table2" runat="server"> <tr> <td class="DatabaseFieldLeft"> <asp:Label ID="Label3" Text="Add Employees:" runat="server" CssClass="" /> </td> <td class="DatabaseFieldRight"> <telerik:RadComboBox ID="EmployeeValue" runat="server" AutoPostBack="true" Width="100%" ShowToggleImage="True" ShowMoreResultsBox="true" EnableVirtualScrolling="true" Height="120px" AllowCustomText="true" EmptyMessage="Please type or select employee name"> <CollapseAnimation Duration="200" Type="OutQuint" /> <ExpandAnimation Type="OutQuart" /> </telerik:RadComboBox> </td> </tr> </table> <br /> </asp:Panel> <asp:Panel ID="SiteSection" runat="server"> <telerik:RadComboBox ID="SitesValue" runat="server"> </telerik:RadComboBox> </asp:Panel> <asp:Label ID="Test" runat="server"></asp:Label> </div> </form></body></html>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using LogicRoster.Business;using Telerik.Web.UI;using EmpowerIT.Applications;using System.Collections;public partial class Utilities_FayezTest : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { EmployeeValue.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(EmployeeValue_SelectedIndexChanged); WorkClassificationValue.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(WorkClassificationValue_SelectedIndexChanged); if(!this.IsPostBack) { EmployeeSection.Visible = true; SiteSection.Visible = false; WorkClassificationValue.Items.Add(new RadComboBoxItem("Item #1", "1")); WorkClassificationValue.Items.Add(new RadComboBoxItem("Item #2", "2")); WorkClassificationValue.Items.Add(new RadComboBoxItem("Item #3", "3")); EmployeeValue.Items.Add(new RadComboBoxItem("Item 1", "1")); EmployeeValue.Items.Add(new RadComboBoxItem("Item 2", "2")); EmployeeValue.Items.Add(new RadComboBoxItem("Item 3", "3")); } } void WorkClassificationValue_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { EmployeeValue.ClearSelection(); EmployeeValue.Text = ""; } void EmployeeValue_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { Test.Text += String.Format("Selected value is: '{0}'<br/>", e.Value); }}
<telerik:GridTemplateColumn DataField="Field1" SortExpression="Field1" UniqueName="Field1
" HeaderText="<%$ Resources:Distributor_resource, Field1%>" AllowFiltering="true" <ItemTemplate> <asp:TextBox ID="txtField1
" runat="server" Text='<%#Bind("Field1")%>'></asp:TextBox> </ItemTemplate> </telerik:GridTemplateColumn>