4 Answers, 1 is accepted
0
Ivan
Top achievements
Rank 1
answered on 16 Dec 2009, 03:41 PM
hello
here is the exception that is thrown
Exception Details: Telerik.Web.UI.GridGroupByException: Field ItemGroup not found in the source table. Please check the expression syntax.
.ASPX PAGE:
<!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">
<div>
<telerik:RadScriptManager ID="cm1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
AllowPaging="True" ShowGroupPanel="false">
<ClientSettings AllowDragToGroup="false" />
<MasterTableView GroupsDefaultExpanded="true" GroupLoadMode="Client">
<GroupByExpressions>
<telerik:GridGroupByExpression>
<GroupByFields>
<telerik:GridGroupByField FieldName="ItemGroup" SortOrder="Ascending" />
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<Columns>
<telerik:GridTemplateColumn HeaderText="Num" GroupByExpression="FNum Num Group By FNum">
<ItemTemplate>
<%# Eval("FNum") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Name" GroupByExpression="StudentName Name Group By StudentName">
<ItemTemplate>
<%# Eval("StudentName") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=IVAN_G\SQLEXPRESS;Initial Catalog=Students;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [FNum], [StudentName], [ItemGroup] FROM [Students]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
CODE:
public class C
{
public int Id { get; set; }
}
public class D : C
{
public int FNum { get; set; }
public string StudentName { get; set; }
public string ItemGroup { get; set; }
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var list = new List<C>();
var o1 = new D();
o1.FNum = 1;
o1.StudentName = "ivan";
o1.ItemGroup = "students";
list.Add(o1);
var o2 = new D();
o2.FNum = 2;
o2.StudentName = "ivan 1";
o2.ItemGroup = "students";
list.Add(o2);
var o3 = new D();
o3.FNum = 3;
o3.StudentName = "ivan 2";
o3.ItemGroup = "techere";
list.Add(o3);
RadGrid1.DataSource = list;
RadGrid1.DataBind();
}
}
I need to bind only to tupeof C objects and use typeof D properties, but it seems that telerik grouping can't fing ItemGroup prop. If I remove the grouping RadGrid Control find all typeof D properties so naturally this should be working with telerik grouping too.
How to do this?
here is the exception that is thrown
Field ItemGroup not found in the source table. Please check the expression syntax.
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: Telerik.Web.UI.GridGroupByException: Field ItemGroup not found in the source table. Please check the expression syntax.
.ASPX PAGE:
<!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">
<div>
<telerik:RadScriptManager ID="cm1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
AllowPaging="True" ShowGroupPanel="false">
<ClientSettings AllowDragToGroup="false" />
<MasterTableView GroupsDefaultExpanded="true" GroupLoadMode="Client">
<GroupByExpressions>
<telerik:GridGroupByExpression>
<GroupByFields>
<telerik:GridGroupByField FieldName="ItemGroup" SortOrder="Ascending" />
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
<Columns>
<telerik:GridTemplateColumn HeaderText="Num" GroupByExpression="FNum Num Group By FNum">
<ItemTemplate>
<%# Eval("FNum") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Name" GroupByExpression="StudentName Name Group By StudentName">
<ItemTemplate>
<%# Eval("StudentName") %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=IVAN_G\SQLEXPRESS;Initial Catalog=Students;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [FNum], [StudentName], [ItemGroup] FROM [Students]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
CODE:
public class C
{
public int Id { get; set; }
}
public class D : C
{
public int FNum { get; set; }
public string StudentName { get; set; }
public string ItemGroup { get; set; }
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var list = new List<C>();
var o1 = new D();
o1.FNum = 1;
o1.StudentName = "ivan";
o1.ItemGroup = "students";
list.Add(o1);
var o2 = new D();
o2.FNum = 2;
o2.StudentName = "ivan 1";
o2.ItemGroup = "students";
list.Add(o2);
var o3 = new D();
o3.FNum = 3;
o3.StudentName = "ivan 2";
o3.ItemGroup = "techere";
list.Add(o3);
RadGrid1.DataSource = list;
RadGrid1.DataBind();
}
}
I need to bind only to tupeof C objects and use typeof D properties, but it seems that telerik grouping can't fing ItemGroup prop. If I remove the grouping RadGrid Control find all typeof D properties so naturally this should be working with telerik grouping too.
How to do this?
0
Hello Ivan,
I am afraid that the collection must be of type "D"(i.e. new List<D>()) to have grouping working correctly.
When you remove GridGroupExpressions RadGrid manages to show the data for the column because it use reflection to bind the values for the current item.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am afraid that the collection must be of type "D"(i.e. new List<D>()) to have grouping working correctly.
When you remove GridGroupExpressions RadGrid manages to show the data for the column because it use reflection to bind the values for the current item.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ivan
Top achievements
Rank 1
answered on 19 Dec 2009, 11:33 AM
yes I understand that but I think that the grouping must work like asp.net binding that doesnt care if I bind to typeof C or D...it finds all properties and bind them correctly
0
Hello Ivan,
To have the ability to group on List<C> RadGrid must use reflection to extract public properties of concrete Item in the collection. As you probably know this could be very slow and will cause performance penalties.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
To have the ability to group on List<C> RadGrid must use reflection to extract public properties of concrete Item in the collection. As you probably know this could be very slow and will cause performance penalties.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.