Hai,
I have a webdatatreee like the below image.
Here, I populate the datatree from datasets. In the datasets, i have one column like 'IS ACTIVE'. It may be 0 or 1.
I want to populate the webdatatree with some color in nodes. Suppose the node has IS ACTIVE field 0 means it will show in red color, and 1 means it will show blue color.
How can i do this?
Thanks in advance.
Hello,
This is Kunal. I am facing the same problem. I have to bind the data fetched from database to the webdatatree with different colors. I am fetching the colors from database itself along with all the other data. Now my question is how to change the text color of the nodes using their respective colors that have been fetched from database?
I am looking forward for your reply.
Thanks,
Kunal.
Hello Thangachan,
Thank you for the update. The following code is going to give you a row in a datatable in that dataset.
((System.Data.DataRowView)(((Infragistics.Web.UI.Framework.Data.DataSetNode)(e.Node.DataItem)).Item)).Row
Then you would access the cells/items of that row through the ItemArray using the index it would be at in your datatable/row.
So for example the first datatable in your grid is the grid level of your tree. Each leaf/node would be a node in that table. Which is what you get with the code I have provided.
In that dataset which i am using to populate the webdatatree, That have more datatables.
then how can i mention the following line:
int value = (int)((System.Data.DataRowView)(((Infragistics.Web.UI.Framework.Data.DataSetNode)(e.Node.DataItem)).Item)).Row.ItemArray[0];
Please help me.
Thank you for contacting Infragistics!
I have done some looking into this matter and have found you can achieve this by handling the NodeBound event of the WebDataTree. In that you can check the value and assign a CssClass to the node based on that value:
protected void WebDataTree1_NodeBound(object sender, DataTreeNodeEventArgs e) { int value = (int)((System.Data.DataRowView)(((Infragistics.Web.UI.Framework.Data.DataSetNode)(e.Node.DataItem)).Item)).Row.ItemArray[0]; if (value == 0) { e.Node.CssClass = "styleNam1"; } else if (value == 1) { e.Node.CssClass = "styleNam2"; } }
Please let me know if you have any further questions concerning this matter.