Treeview Binding

Discussion in 'ASP .Net Web Controls' started by Michel, Aug 24, 2007.

  1. Michel

    Michel Guest

    Is there a better way to filter unwanted nodes to appear in the Treview ?

    All I found is this :

    void wTree_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    {
    if (e.Node.Text == "Var")
    {
    e.Node.Parent.ChildNodes.Remove(e.Node);
    }
    }

    Not very elegant or efficient...
    --
    Michel
     
    Michel, Aug 24, 2007
    #1
    1. Advertising

  2. Michel

    Manish Bafna Guest

    Hi,
    I would suggest you filter at datatable level.You must be databinding
    dataset or datatable to treeview.Try something like this:
    DataView myView =Dataset1.Tables[0].DefaultView;
    myView.RowFilter = "Description LIKE '%" + strSearch.Text +
    "%' or Model LIKE '%" + strSearch.Text + "%' ";
    For more info on how to use filter refer below link:
    http://authors.aspalliance.com/aspxtreme/sys/data/dataviewclassrowfilter.aspx
    --
    Hope this answers your question.
    Thanks and Regards.
    Manish Bafna.
    MCP and MCTS.



    "Michel" wrote:

    > Is there a better way to filter unwanted nodes to appear in the Treview ?
    >
    > All I found is this :
    >
    > void wTree_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    > {
    > if (e.Node.Text == "Var")
    > {
    > e.Node.Parent.ChildNodes.Remove(e.Node);
    > }
    > }
    >
    > Not very elegant or efficient...
    > --
    > Michel
     
    Manish Bafna, Aug 25, 2007
    #2
    1. Advertising

  3. Michel

    Michel Guest

    Hello,

    I should have been more clear, sorry!

    My XmlDataSource is loaded from an XML file which serves many purposes...

    dataSource = new XmlDataSource();
    dataSource.ID = "CatalogDataSource";
    dataSource.DataFile = "xml/catalog.xml";
    dataSource.XPath = "/Catalog/Cat";

    I did not find a way to filter out unwanted nodes directly in the
    dataSource...

    "Catalog" is the root, "Cat" are categories nodes; I don't want other node
    types.

    I was hoping to be able to specify a filter in the XPath property ?

    Thanks,

    --
    Michel


    "Manish Bafna" wrote:

    > Hi,
    > I would suggest you filter at datatable level.You must be databinding
    > dataset or datatable to treeview.Try something like this:
    > DataView myView =Dataset1.Tables[0].DefaultView;
    > myView.RowFilter = "Description LIKE '%" + strSearch.Text +
    > "%' or Model LIKE '%" + strSearch.Text + "%' ";
    > For more info on how to use filter refer below link:
    > http://authors.aspalliance.com/aspxtreme/sys/data/dataviewclassrowfilter.aspx
    > --
    > Hope this answers your question.
    > Thanks and Regards.
    > Manish Bafna.
    > MCP and MCTS.
    >
    >
    >
    > "Michel" wrote:
    >
    > > Is there a better way to filter unwanted nodes to appear in the Treview ?
    > >
    > > All I found is this :
    > >
    > > void wTree_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    > > {
    > > if (e.Node.Text == "Var")
    > > {
    > > e.Node.Parent.ChildNodes.Remove(e.Node);
    > > }
    > > }
    > >
    > > Not very elegant or efficient...
    > > --
    > > Michel
     
    Michel, Aug 27, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordan
    Replies:
    2
    Views:
    2,539
    Jordan
    Feb 10, 2004
  2. Amit
    Replies:
    6
    Views:
    13,811
    Assimalyst
    Oct 24, 2006
  3. Replies:
    2
    Views:
    867
    Kevin Grover
    Oct 20, 2006
  4. JcFx
    Replies:
    0
    Views:
    281
  5. Vivek Nallur

    value binding and function binding

    Vivek Nallur, Sep 25, 2003, in forum: Ruby
    Replies:
    0
    Views:
    138
    Vivek Nallur
    Sep 25, 2003
Loading...

Share This Page