Change color of treeview text from sql

2 posts, 0 answers
  1. Herman
    Herman avatar
    28 posts
    Member since:
    Jun 2011

    Posted 05 Jul 2011 Link to this post

    Apologies for my English

    I create my treeview from a SQL database. In my database  have with all the other data  two columns
    1. Active(bit) true or false
    2. Status(nvchar)

    when the treeview is build on the load i want the colors to look like this

    • Node titles displayed in “Green” RGB[102, 188, 41] are Active (Active Flag is true) nodes with an approval status of “Approved”
    • Node titles displayed in “Amber” RGB [255, 145, 75] are Active nodes that have an approval status of “Pending”
    • Node titles displayed in “Red” RGB [210, 90, 90] are Active nodes that have an approval status of “Rejected”
    • Node titles displayed in “Grey” RGB[128, 128, 128] are Inactive regardless of the value of the approval status.


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Jul 2011 Link to this post

    Hello Herman,

    You can set the desired color in the NodeDataBound event. Here is the sample code.
    C#:
    protected void RadTreeView1_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
       {
           if (e.Node.Text == "Test")
           {
               e.Node.ForeColor = System.Drawing.Color.Red;
           }
       }

    Thanks,
    Shinu.
Back to Top