Custom node styles for specific fields when using DataSource

3 posts, 1 answers
  1. Ray Bezuidenhout
    Ray Bezuidenhout avatar
    6 posts
    Member since:
    Apr 2004

    Posted 23 Feb 2011 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Feb 2011 Link to this post

    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.
  3. Ray Bezuidenhout
    Ray Bezuidenhout avatar
    6 posts
    Member since:
    Apr 2004

    Posted 24 Feb 2011 Link to this post

    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
Back to Top