I am using telerik grid and data is bound programatically to the grid.
When i allow grouping in the client side and drag and drop columns to group it throws the error shown beolw (even after setting the groupby expressions for the columns).Please find the code to populate grid and the apsx content at the end of the mail.
Expression cannot be null or empty
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: Expression cannot be null or empty
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:
|
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
ASPX Content of grid:
<telerik:RadGrid ID="RadGrid1" runat="server"
AllowCustomPaging="True"
AutoGenerateColumns="False"
AllowPaging="True"
AllowFilteringByColumn="True"
AllowSorting="True"
GridLines="None"
ShowGroupPanel="True"
GroupingEnabled="True"
ongridexporting="RadGrid1_GridExporting1"
onpdfexporting="RadGrid1_PdfExporting"
onpageindexchanged="RadGrid1_PageIndexChanged1"
ongroupschanging="RadGrid1_GroupsChanging" onneeddatasource="RadGrid1_NeedDataSource">
<
MasterTableView>
<
RowIndicatorColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
RowIndicatorColumn>
</
MasterTableView>
<
ClientSettings AllowDragToGroup="true">
</ClientSettings>
<
PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" />
<
FilterMenu EnableTheming="True">
<
CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</
FilterMenu>
</telerik:RadGrid>
Code:
public
void PopulateGrid()
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM abc", "server=10.100.111.11;database=abcd;Uid=aa;pwd=aa;");
adapter.Fill(ds);
foreach (DataColumn col in ds.Tables[0].Columns)
{
GridBoundColumn gridboundcolumn = new GridBoundColumn();
gridboundcolumn.DataField = col.ColumnName;
gridboundcolumn.HeaderText = col.ColumnName
;
gridboundcolumn.UniqueName = col.ColumnName;
gridboundcolumn.SortExpression = col.ColumnName;
gridboundcolumn.Display =
true;
gridboundcolumn.Groupable =
true;
gridboundcolumn.GroupByExpression = gridboundcolumn.GetDefaultGroupByExpression();
RadGrid1.Columns.Add(gridboundcolumn);
}
RadGrid1.VirtualItemCount = 2000;
RadGrid1.DataBind();
}