This is a migrated thread and some comments may be shown as answers.

ItemsSource = DataTable -> SearchPanel System.ArgumentException

2 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Philipp
Top achievements
Rank 1
Philipp asked on 09 Mar 2016, 07:49 PM

Hello,

if i bind a DataTable to a RadGridView.ItemsSource and try to search with SearchPanel, i'm getting a System.ArgumentException error.

Column 'xy' does not belong to table xy.

Can you help me please? Thanks.

 

<telerik:RadGridView ItemsSource="{Binding Table}" ShowSearchPanel="True"/>

 

private DataTable _table;
 
public DataTable Table
{
    get { return _table; }
    set
    {
        if (Equals(value, _table)) return;
        _table = value;
        OnPropertyChanged(nameof(Table));
    }
}
 
 
public ViewModel()
{
    Table = new DataTable("Test");
    Table.Columns.Add("Spalte 1");
    Table.Columns.Add("Spalte 2");
    Table.Columns.Add("Spalte 3");
 
    for (var i = 0; i < 50; i++)
    {
        var row = Table.NewRow();
        row.ItemArray = new object[] { "Cell 1 " + i, "Cell 2 " + i, "Cell 3 " + i };
        Table.Rows.Add(row);
    }
}

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 10 Mar 2016, 07:47 AM
Hi Philipp,

Indeed, you are absolutely right. I managed to reproduce the issue quite easily thanks to the snippets you provided. We will investigate the case further. In the meantime, could you try working with DefaultView instead? For example:
<telerik:RadGridView ItemsSource="{Binding Table.DefaultView}" ShowSearchPanel="True"/>

Will that approach meet your requirements?

Regards,
Maya
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Philipp
Top achievements
Rank 1
answered on 10 Mar 2016, 10:10 AM

Hi Maya,

thank you for reply. DefaultView works for me!

Regards,
Philipp

Tags
GridView
Asked by
Philipp
Top achievements
Rank 1
Answers by
Maya
Telerik team
Philipp
Top achievements
Rank 1
Share this question
or