Binding Dataset with Filter causes Problems

2 posts, 0 answers
  1. Karl Golling
    Karl Golling avatar
    226 posts
    Member since:
    Jun 2005

    Posted 11 Jun 2012 Link to this post

    Hi,

    In the code below I have a dataset connected to a radTreeView. It is recursive and it works. When I try to filter the dataset with the .Select command the radTreeView knows there is data there but the displaymember stays blank - meaning no text in the tree. Why?

    Thanks,
    Karl 

    private void BindLangDataToTree()
    {
        this.radTreeView1.DisplayMember = "Thema_" + myLang; ;
        this.radTreeView1.ParentMember = "pid";
        this.radTreeView1.ChildMember = "id";
        this.radTreeView1.ValueMember = "id";
        radTreeView1.DataSource =  ds_Baum.Tables["Baum"];//.Select("Schule='" + mySchuleID + "'");
    }
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 13 Jun 2012 Link to this post

    Hi Karl,

    Please use the RowFilter property of DefaultView to filter data instead of the Select method of DataSet to save the data binding consistency and performance of your application. Here is the changed code snippet:
    private void BindLangDataToTree()
    {
        this.radTreeView1.DisplayMember = "Thema_" + myLang; ;
        this.radTreeView1.ParentMember = "pid";
        this.radTreeView1.ChildMember = "id";
        this.radTreeView1.ValueMember = "id";
        ds_Baum.Tables["Baum"].DefaultView.RowFilter = "Schule='" + mySchuleID + "'";
        radTreeView1.DataSource = ds_Baum.Tables["Baum"];
    }

    I hope this helps. Let me know if you need further assistance.

    Kind regards,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top