Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:22:36+00:00 2026-05-27T01:22:36+00:00

I want to set the node colors of a treeview at runtime. I populate

  • 0

I want to set the node colors of a treeview at runtime. I populate the treeview from a collection that has the parentid, childid, and description, and I’ve added a property representing the color I want applied to the node. FWIW the source is a database, the app is C#.

In a gridview I use RowDataBound() to programmatically affect the control. Im not sure how to do so in the treeview, including which event to use (DataBound()? TreeViewDataBound()?). My research has not been fruitful so far. A code snippet would be very useful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:22:36+00:00Added an answer on May 27, 2026 at 1:22 am

    Assuming you are dealing with the standard TreeView control, you can do this in the TreeDataBound Event.

    A brief example (not tested):

    <asp:TreeView runat="server"
        ID="tvMyTreeView"
        OnTreeNodeDataBound="tvMyTreeView_TreeNodeDataBound"
        />
    

    And the backend:

    protected void tvMyTreeView_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    {
        DataRowView dr = (DataRowView)e.Node.DataItem;
        e.Node.Style.Add("color", dr["COLOR"].ToString());
    }
    

    If you are using the Telerik RadTreeView, then the event name is NodeDataBound

    You will probably have to tweak the example to better fit your needs, but hopefully this will get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a function that returns the full path from a set
I want to set something up so that if an Account within my app
I want to set a background image for a div, in a way that
I can set the Treeview selected node using code, but it's appearance does not
I want to set text of some node found by xpath() <?php $args =
I have node set with header, leading, body text etc... I want to make
How can we create a node set from values.... I have n numbers 1,2,3.......n.
The CellTree has a constructor that takes a TreeModel. I can't set the tree
I'm creating a base class Node that essentially wraps instances of another class from
I have a List of type Node. I want to set a temporary Node

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.