ItemsSource = DataTable -> SearchPanel System.ArgumentException

3 posts, 0 answers
  1. Philipp
    Philipp avatar
    4 posts
    Member since:
    Nov 2015

    Posted 09 Mar Link to this post

    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. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 10 Mar Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Philipp
    Philipp avatar
    4 posts
    Member since:
    Nov 2015

    Posted 10 Mar Link to this post

    Hi Maya,

    thank you for reply. DefaultView works for me!

    Regards,
    Philipp

Back to Top