Treeview Binding

M

Michel

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...
 
M

Michel

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 said:
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 said:
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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top