I have a screen with a radgrid that is filled using the NeedDataSource Event
This works fine as long as I have the page setting
but when I Filter from multilpe columns it only sorts the last column selected. When I change the EnableViewState to TRUE, I get an error in the Filter in Dynamic.cs
"No applicable indexer exists in type '<>f__AnonymousType50`12'"
When I look at teh filter expression it shows
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
int count = 0;
if (RadGrid1.MasterTableView.SortExpressions.Count > 0)
RadGrid1.DataSource = GetEntities(RadGrid1.PageSize, RadGrid1.MasterTableView.CurrentPageIndex * RadGrid1.PageSize, RadGrid1.MasterTableView.FilterExpression,
RadGrid1.MasterTableView.SortExpressions[0].FieldName + " " + RadGrid1.MasterTableView.SortExpressions[0].SortOrderAsString(), out count);
else
RadGrid1.DataSource = GetEntities(RadGrid1.PageSize, RadGrid1.MasterTableView.CurrentPageIndex * RadGrid1.PageSize, RadGrid1.MasterTableView.FilterExpression, "", out count);
RadGrid1.MasterTableView.VirtualItemCount = count;
}
private DataTable GetEntities(int maximumRows, int startRowIndex, string filterExpression, string sortExpression, out int count)
{
ClientDataContext db = new ClientDataContext();
var query = from g in db.GovtEntityLogs
select new
{
g.GovtEntityLogID,
g.ClientID,
g.Client.ClientName,
g.EntityName,
g.StartDate,
g.EndDate,
g.InvestorTypeID,
g.InvestorType.InvestorType1,
};
//Set filter expresion
if (!String.IsNullOrEmpty(filterExpression))
{
query = query.Where(String.Format(@"{0}", filterExpression));
}
if (!String.IsNullOrEmpty(sortExpression))
{
query = query.OrderBy(sortExpression);
}
else
{
query = query.OrderBy("ClientName");
}
//Set the total row count
count = query.Count();
var pagedData = query.Skip(startRowIndex).Take(maximumRows);
DataTable dt = new DataTable();
dt = pagedData.ToADOTable();
return dt;
}
This works fine as long as I have the page setting
<%@ Page Title="" EnableViewState="false"
but when I Filter from multilpe columns it only sorts the last column selected. When I change the EnableViewState to TRUE, I get an error in the Filter in Dynamic.cs
"No applicable indexer exists in type '<>f__AnonymousType50`12'"
When I look at teh filter expression it shows
"(Convert.ToString(it[\"ClientName\"]).ToUpper() = \"Capital Investment Advisory Services, LLC (CIAS)\".ToUpper())"
Am I missing something?