我有一个返回8000结果的网格,我想按日期过滤这些结果并将它们存储到一个新的数据表中,然后重新绑定。我收到此错误:
Input array is longer than the number of columns in this table.
我有什么选择?
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);
}
}
答案 0 :(得分:1)
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);
}
}
您必须向DataTable标准添加列。物品无法添加到任何地方。
答案 1 :(得分:0)