Reputation: 2261
I have a grid that returns 8000 results, and I would like to filter these results by date and store them into a new datatable and rebind later. I receive this error:
Input array is longer than the number of columns in this table.
What are my options?
if (e.CommandName == "Filter")
{
DataTable dt = new DataTable();
foreach (GridDataItem item in RadGrid2.Items)
{
for (int i = 0; i < RadGrid2.Items.Count; i++ )
{
dt.Rows.Add(item);
}
}
Upvotes: 0
Views: 1845
Reputation: 62260
Returning 8000 results to RadGrid is too much.
Please consider using AllowCustomPaging, and retrieve only the rows you need to display.
For example, using Skip and Take in Entity Framework.
Upvotes: 0
Reputation: 769
if (e.CommandName == "Filter")
{
DataTable dt = new DataTable();
td.Columns.Add("Column1");
td.Columns.Add("Column2");
//etc.
//add same columns as you have in RadGrid2
foreach (GridDataItem item in RadGrid2.Items)
{
for (int i = 0; i < RadGrid2.Items.Count; i++ )
{
dt.Rows.Add(item);
}
}
You have to add columns to your DataTable td. Items cannot be added to nowhere.
Upvotes: 1