(I am posting this thread here because I didn't get any reply in GRID setion of forum yet)
Hi,
I need to create hierarchical rad grid programatically using DataTable, but I'm having a problem in settng the data source for level 1 hierarchy. When I try to expand the child table, an exception is thrown as
"Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand before 'Is' operator."
Kindly help me out regarding this issue. I have attached my code and exception trace. Thanks
Regards
Muhammad Farjad
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
</Scripts>
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<div>
<telerik:RadGrid ID="RadGrid1" runat="server" ondetailtabledatabind="RadGrid1_DetailTableDataBind">
</telerik:RadGrid>
</div>
</form>
</body>
---------------------------------------------------- Code Behind File ----------------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Add grand father table
DataTable grandFatherTable = CreateDataTable("GrandFather");
AddDataToTable("usman", "Usman", "Mansur", grandFatherTable);
AddDataToTable("adnan", "Adnan", "Ahmad", grandFatherTable);
AddDataToTable("nabeel", "Nabeel", "Ahmed", grandFatherTable);
RadGrid1.DataSource = grandFatherTable;
RadGrid1.MasterTableView.DataKeyNames = new string[] { "username" };
RadGrid1.Width = Unit.Percentage(98);
RadGrid1.PageSize = 5;
RadGrid1.AllowPaging = true;
//RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
RadGrid1.AutoGenerateColumns = false;
RadGrid1.Skin = "Web20";
RadGrid1.MasterTableView.PageSize = 15;
RadGrid1.MasterTableView.Width = Unit.Percentage(100);
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "username";
boundColumn.HeaderText = "User Name";
boundColumn = new GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "firstname";
boundColumn.HeaderText = "First Name";
boundColumn = new GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "lastname";
boundColumn.HeaderText = "Last Name";
//Add Father table
DataTable fatherTable = CreateDataTable("Father");
AddDataToTable("usman", "u1", "u2", fatherTable);
AddDataToTable("adnan", "a1", "a2", fatherTable);
AddDataToTable("nabeel", "n1", "n2", fatherTable);
GridTableView tableViewFather = new GridTableView(RadGrid1);
tableViewFather.Width = Unit.Percentage(100);
tableViewFather.DataSource = fatherTable;
tableViewFather.DataKeyNames = new string[] { "username" };
GridRelationFields relationFields = new GridRelationFields();
relationFields.MasterKeyField = "username";
relationFields.DetailKeyField = "username";
tableViewFather.ParentTableRelation.Add(relationFields);
RadGrid1.MasterTableView.DetailTables.Add(tableViewFather);
boundColumn = new GridBoundColumn();
tableViewFather.Columns.Add(boundColumn);
boundColumn.DataField = "username";
boundColumn.HeaderText = "User Name";
boundColumn = new GridBoundColumn();
tableViewFather.Columns.Add(boundColumn);
boundColumn.DataField = "firstname";
boundColumn.HeaderText = "First Name";
boundColumn = new GridBoundColumn();
tableViewFather.Columns.Add(boundColumn);
boundColumn.DataField = "lastname";
boundColumn.HeaderText ="Last Name";
}
}
private DataTable CreateDataTable(string tableName)
{
DataTable myDataTable = new DataTable(tableName);
DataColumn myDataColumn;
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "username";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "firstname";
myDataTable.Columns.Add(myDataColumn);
myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.String");
myDataColumn.ColumnName = "lastname";
myDataTable.Columns.Add(myDataColumn);
return myDataTable;
}
private void AddDataToTable(string username, string firstname, string lastname, DataTable myTable)
{
DataRow row;
row = myTable.NewRow();
//row["id"] = Guid.NewGuid().ToString();
row["username"] = username;
row["firstname"] = firstname;
row["lastname"] = lastname;
myTable.Rows.Add(row);
}
protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
{
DataTable fatherTable = CreateDataTable("Father");
AddDataToTable("usman", "u1", "u2", fatherTable);
AddDataToTable("adnan", "a1", "a2", fatherTable);
AddDataToTable("nabeel", "n1", "n2", fatherTable);
e.DetailTableView.DataSource = fatherTable;
}
}
---------------------------------------------------------- exception ------------------------------------------------------------------------
Server Error in '/RadHierarchicalGrid' Application.
--------------------------------------------------------------------------------
Syntax error: Missing operand before 'Is' operator.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand before 'Is' operator.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SyntaxErrorException: Syntax error: Missing operand before 'Is' operator.]
System.Data.ExpressionParser.Parse() +4824040
System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +121
System.Data.DataView.set_RowFilter(String value) +153
System.Data.LinqDataView.set_RowFilter(String value) +53
Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +375
Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +21
Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray) +105
Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +432
Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +500
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() +4
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
Telerik.Web.UI.GridTableView.DataBind() +224
Telerik.Web.UI.GridDataItem.OnExpand() +272
Telerik.Web.UI.GridItem.set_Expanded(Boolean value) +109
Telerik.Web.UI.GridExpandCommandEventArgs.ExecuteCommand(Object source) +34
Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +134
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +115
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage2.master.cs" Inherits="MasterPages_MasterPage2" %><!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> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <div> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form></body></html>using System;public partial class MasterPages_MasterPage2 : System.Web.UI.MasterPage{ protected void Page_Load(object sender, EventArgs e) { }}<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MasterPage2.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:LinkButton ID="lb1" runat="server" OnClick="lb1_Click" Text="push" /> <asp:Label ID="lbl1" runat="server" Text="test" /> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" UpdatePanelsRenderMode="Inline"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="lb1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="lbl1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager></asp:Content>using System;public partial class Default3 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void lb1_Click(object sender, EventArgs e) { lbl1.Text = "pushed"; }}<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!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"><telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> <asp:LinkButton ID="lb1" runat="server" OnClick="lb1_Click" Text="push" /><asp:Label ID="lbl1" runat="server" Text="test" /><telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" UpdatePanelsRenderMode="Inline"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="lb1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="lbl1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager></form></body></html>using System;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void lb1_Click(object sender, EventArgs e) { lbl1.Text = "pushed"; }}<httpRuntime maxRequestLength="209715200" enable="true" useFullyQualifiedRedirectUrl="true" executionTimeout="3600" /> ... <requestLimits maxAllowedContentLength="209715200"/><telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel2"> <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="300" Height="300" Label="Select people:" EmptyMessage="Type a persons name" AllowCustomText="true" MarkFirstMatch="True" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="Name" Filter="Contains" EnableAutomaticLoadOnDemand="True" EnableVirtualScrolling="true" ItemsPerRequest="15" /></telerik:RadAjaxPanel><ClientSettings AllowKeyboardNavigation="False"> <ClientEvents OnKeyPress="BlockEnterKey" /> <KeyboardNavigationSettings AllowSubmitOnEnter="false" /></ClientSettings><script type="text/javascript"> function BlockEnterKey(sender, e) { if (e.get_keyCode() == 13) { alert('Blocking Enter KeyPress'); e.set_cancel(true); e.cancelBubble = true; return false; } }</script><add key="Telerik.Skin" value="Office2010Blue" /><add key="Telerik.StyleSheetManager.TelerikCdn" value="Enabled" /><add key="Telerik.StyleSheetManager.TelerikCdn.BaseUrl" value="http://www.abc.com/Skins" /><add key="Telerik.StyleSheetManager.TelerikCdn.BaseSecureUrl" value="https://www.abc.com/Skins" /><add key="Telerik.ScriptManager.TelerikCdn" value="Enabled" /><add key="Telerik.ScriptManager.TelerikCdn.BaseUrl" value="http://www.abc.com/Scripts" /><add key="Telerik.ScriptManager.TelerikCdn.BaseSecureUrl" value="https://www.abc.com/Scripts" /><%@ Master Language="VB" CodeFile="MasterABC.master.vb" Inherits="MasterABC" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> <title> ABC, Inc. </title> <link href="~/Styles/ABC/Site.css" rel="stylesheet" type="text/css"/> <script type="text/javascript"> window.history.forward(1); </script> <style type="text/css"> .RadMenu .rmLink .rmText { font-family: Arial; font-size: 12pt !important; } </style> </head> <body id="mainBody" runat="server"> <script type="text/javascript"> var flag = false;</script> <script type="text/javascript"> var AjaxIsActive = false; function RequestSent() { if (!AjaxIsActive) { AjaxIsActive = true; } else { alert('Wait for Page to Load'); return false; } } function ResponseEnd() { AjaxIsActive = false; } </script> <form id="form1" runat="server"> <center> <div> <telerik:RadScriptManager ID="ScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Office2010Blue" EnableRoundedCorners="true" /> <table id="header" runat="server"> <tr> <td align="left" style="width:300px"> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </td> <td valign="bottom" align="right"> <asp:Label ID="FN" runat="server" Font-Size="X-Large"></asp:Label> <br/> <asp:Label ID="MN" runat="server" Font-Size="X-Large"></asp:Label> <table> <tr> <td style="text-align:left"> <telerik:RadMenu ID="Menu1" Skin="Office2010Blue" Runat="server" EnableRoundedCorners="true"> </telerik:RadMenu> </td> </tr> </table> </td> </tr> </table> </div><script src="https://www.abc.com/Scripts/ajaxz/2012.2.912/Common/Core.js" type="text/javascript"></script><script src="https://www.abc.com/Scripts/ajaxz/2012.2.912/FormDecorator/RadFormDecorator.js" type="text/javascript"></script><script src="https://www.abc.com/Scripts/ajaxz/2012.2.912/Common/jQuery.js" type="text/javascript"></script>HTTP/1.1 200 OKCache-Control: privateContent-Length: 190405Content-Type: text/html; charset=utf-8Server: Microsoft-IIS/7.0X-AspNet-Version: 4.0.30319X-Powered-By: ASP.NETX-UA-Compatible: IE=7Date: Wed, 12 Jun 2013 02:27:44 GMT<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> .style2 { text-decoration: underline; font-size: x-large; font-family: "Century Gothic"; } .style3 { font-size: x-small; } </style> <style id="head_Style1" type="text/css"> .radupload { float: left; margin-bottom:20px; } .bigModule { clear: both; } .smallModule { margin-bottom:20px; } #controlContainer { vertical-align: top; padding: 20px 10px; } .ruProgressArea { position: absolute; top: 0; left: 10px; } input.RadUploadSubmit { margin-top: 20px; } </style><title> ABC, Inc. </title><link href="../Styles/ABC/Site.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> window.history.forward(1); </script> <style type="text/css"> .RadMenu .rmLink .rmText { font-family: Arial; font-size: 12pt !important; } </style> <link href="/WebResource.axd?d=7209tdxJpyfYvktO7sizLvEsOlAAECN6K3FRNE-PHZRYrWNeNFtBXQbsuC66ijzjVL0YeGYekDhirFbodcA8dpuxgxZPT8bwHQHFPZyOQ2iqctHlDW0PZsNDzijuaY-F9SFdS25jptZEXW79Bmhleg2&t=635064967590027882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=oq7JFUamAGDDod2zl0bRxmoJJl3MRXXYu9kGCqiBtsYNl3E2SE-cNLPrh4Z52YMLXfCf6vb6jowUyroohPh9BcVgQsAAgkdFkphvW5mXNHdKHmzeS4ffBCFyHl1muhvxTjqqvj750FHAPhzOWP4p_8LUIeOfUEB2GwzsiGGEDo7yk5A1tAra8OZ37McbfvMZJqpBeNa1eY4zZkAT-bWnkw2&t=635064967433091882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=yy_i9ieMBzMnZQru3Pdp-zv5fihc_8qUAWmz-JfbtmatlOKdAdpVPAYNUt3O-d6QdSEuR2_ahVoERJg0K9jaDYRAnYSzqZWRV7fcIxOkJzDVE5Qsac_WdE5bw9-deq7jEYIR0qvVMitLCOowjXNTEg2&t=635064967590027882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=VtOfGwNPga3C32XTXimW7I0iuwKw7q6nlUWQzFSZvIkA3nloS3c_wY6se-UcEMduObX2VkCty-gbAvvT_chGRo4JaWsE88soNMM-YUGkYzt1_afGccaeDqGdAmiBvWdDsOvvF33hxOE4iX-mwIeEreQKhCx99kTcpluI-o0ZOIZePR_wuFI7bPQfM_opYTHJ0&t=635064967433091882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=VcxTCfx6wBSYwXw0sOU10ZoD0BU8xX4nQNF3GOxhH4nyqNQt7WniM-nOhpQoxW9vTYsynZPKzhcTCTZeUme-ha2rHAS-AkT_PjCd1jIWd-53Tq7ZNtOAaI6i_pj0GcVIUx2yBb6eF3k4Tqp4ovTYhA2&t=635064967590027882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=ZMrtlghAh8mu8vLQWv-nO0H8hkPsZQwoKKob-VFVGUB10sHtNv6dGANGwRNh7UaoJdM_QL3rqhAT-P46VJ4SJFRhFScY0IzytWrUB3rGnCMT76L6sIPKFG_xlf_blMjge8cHLiWA7P6K9x24YUMoHL38fQuancEYYsebGUUf7Du_5fKPuUAKqZnrr4pOMTAL0&t=635064967433091882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=ZJhKpdZwpS108KbGM0H2TZF_EWXJ4ECWG1Em-Y-GDt1JRcBLtb_n2Nkb13OOqzL9ixP_bbA93c6CEug8ADqXsal460faur731RPCxOe64pag9YDtLe1flnIHrE2s1TXU8GvrT6WljonOhkC9MBq11Q2&t=635064967590027882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=6ON68SCi2xXHwqc4l3uDtRUR00KLUtKpyL_08eHIsXtKlSbYpsiMe_fi33NHzkpPSrlSlFoCSH4gM40PHWmJoE6_xmqvfILfF0NpAhPAIq2fKYoqSO6ffH0KkQGDHXuSE5onleMaL_95WcUX0XPAitYQREHLVOg7YCoVIgyaFGwazHIZuC-lCRdnVt6rcQq5vbs4Rl7UKFA7ULhmYqwJ_g2&t=635064967433091882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=GdWx2IEl9qeAVSBk_wNbtNNfEEr0RDfJhzZbTLHshjF4JMq2C4mKXlIz0U2SD09ysHUnonI6eVFFELGv-AolOh_uMtQoKflJ5dBVi-wNg1X66ES6cZLnUe_3rhQGsvuwtjwQcKNc2vWsf-cEPAVvQQ2&t=635064967590027882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=QfqpEg8bjesXMy-Al9qTqzOqfrDgRid_4ywST7dqgWdhsfB5o1itTDWVLGQVdSmniXGMswew3hXDtq5VwkYPIn76ozSw62N0L6UY2qY3t-kvi3R92WRDVLIcKf_M-BOisSVuQdtZ93YgAwJRkAiwaFt_Jq6_ueopk3mjmGXaMGguF6mUi7gCKJSUkDXp4Cw-0&t=635064967433091882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=sXVgqmZA3Vi0qJFOU8bZCafGsK-iAaxh4R2-tqOSGWTirEMClpnJj4__rOPTYn_P5iel6KpdYdI6B3cpXFv-XvpJgqbdC8RtGtOGnTY8KyhZCefwANsIULOxvwcmRjSgeOShII4cMgi0U27lUKjLHg2&t=635064967590027882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=s0JUHkkrBHaA8138SQ5FzmmohQq9va8KLWcjWENuWi2H2b0ojbgGxC-LT2OL9XlKiNR3kSFY7A95TAUSaXQcr0utOQJHhD4pLFF7CqwBTBp3opqxAGBXVSOygHtRu04DqteLyX34bwtUwQDYb16nvvw4CZgDKsmedNEnp3CmKCiLHJOqVVKdSzWH2-gUny9K0&t=635064967433091882" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /></head> <body id="mainBody" bgcolor="f2dd95" style="background-image: url(/Decoration/2/BG1.png)">