Nate Bross
Well-known member
I have this code which works great
The issue is that if I change the properties of dgvMyTasks to allow paging, I get the error "this object does not support server-side data paging"
I have created this workaround, but Im wondering if there is a better way:
I got the workaround above with the loop since this, more direct approach (type cast):
throws the exception "unable to cast from type WhereIterator to Task.
The Linq query is the same in all three code snippets.
Is there a better solution out there?
Code:
var newList = new Object();
newList = from Task t in FoundTasks
where t.TaskStatus.Contains(sStatusFilter) &&
t.TaskType.Contains(sTaskFilter)
select t;
// bind the result to the data grid
dgvMyTasks.DataSource = newList;
dgvMyTasks.DataBind();
The issue is that if I change the properties of dgvMyTasks to allow paging, I get the error "this object does not support server-side data paging"
I have created this workaround, but Im wondering if there is a better way:
Code:
List<Task> newList = new List<Task>();
foreach (Task t in (from Task t in FoundTasks
where t.TaskStatus.Contains(sStatusFilter) &&
t.TaskType.Contains(sTaskFilter)
select t))
{
newList.Add(t);
}
// bind the result to the data grid
dgvMyTasks.DataSource = newList;
dgvMyTasks.DataBind();
I got the workaround above with the loop since this, more direct approach (type cast):
Code:
List<Task> newList = new List<Task>();
newList = (List<Task>)from Task t in FoundTasks
where t.TaskStatus.Contains(sStatusFilter) &&
t.TaskType.Contains(sTaskFilter)
select t;
// bind the result to the data grid
dgvMyTasks.DataSource = newList;
dgvMyTasks.DataBind();
throws the exception "unable to cast from type WhereIterator to Task.
The Linq query is the same in all three code snippets.
Is there a better solution out there?