This is a migrated thread and some comments may be shown as answers.

Custom node styles for specific fields when using DataSource

2 Answers 53 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ray Bezuidenhout
Top achievements
Rank 1
Ray Bezuidenhout asked on 23 Feb 2011, 05:32 PM
Hi,

How can I set the colour/style of specific nodes according to the value of a field in a datasource? For example, if I assign a datasourceid for the treeview which has a boolean/bit field then the nodes that have a value of true/1 should be bold.

Regards,
Ray

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Feb 2011, 11:00 AM
Hello Ray,


I believe, you can perform this in NodeDataBound event. In the handler, check for the boolean value and access the node and set the Font.Bold property to True.


-Shinu.
0
Ray Bezuidenhout
Top achievements
Rank 1
answered on 24 Feb 2011, 02:59 PM
Brilliant, thanks for the heads-up.

For other's looking for a similar solution,  I basically just used:

protected void RadTreeView1_NodeDataBound(object sender, RadTreeNodeEventArgs e)
{
    if ((Boolean)DataBinder.Eval(e.Node.DataItem, "Discounted") == true)
    {
           e.Node.CssClass = "bold";
    }           
}

Regards,
Ray
Tags
TreeView
Asked by
Ray Bezuidenhout
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ray Bezuidenhout
Top achievements
Rank 1
Share this question
or