Change background of specific items

4 posts, 0 answers
  1. Oscar Emiliano
    Oscar Emiliano avatar
    20 posts
    Member since:
    Sep 2013

    Posted 08 Aug 2014 Link to this post


    I was looking for a way that allow me to change the background color of certain elements. For example, my dropdownlist is showing the name of Users, but I would like to present with a different background those Users that are inactive. With regular dropdownlist I was able to do this on DataBound method. Is it possible to do something similar with RadDropDownList?

    Background color is for the moment my requirement, but of course an answer that allow me to change any css attribute would be even better (font size, color, style, etc).

    Thanks in advance of your support

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

    Posted 11 Aug 2014 in reply to Oscar Emiliano Link to this post

    Hi Oscar,

    Below is the sample code snippet to achieve your scenario. I have set one Boolean value for the Active Users and set it as a DataValueField of RadDropDownList. In ItemDataBound event based on the value I am setting the Color and Font-size of a User in the list.

    <telerik:RadDropDownList ID="rddlTestDemo" DataSourceID="sqldsUsers" DataTextField="UserName"
        DataValueField="Active" runat="server" OnItemDataBound="rddlTestDemo_ItemDataBound">

    protected void rddlTestDemo_ItemDataBound(object sender, Telerik.Web.UI.DropDownListItemEventArgs e)
        if (e.Item.Value == "False")
            //inactive user
            e.Item.CssClass = "inactive-user";
            //active user
            e.Item.CssClass = "active-user";

    <style type="text/css">
            color :Red !important;
            font-size : medium !important;
            color:Green !important;
            font-size : large !important;

  3. michael
    michael avatar
    11 posts
    Member since:
    Apr 2016

    Posted 16 Nov 2017 in reply to Shinu Link to this post


    I need to do something similar. My list says "Red" "Green" "Blue" etc.

    Is there a way to do that? I tried the following but it did not work.

    "dd" is my RadDropdownList

            For i As Integer = 0 To dd.Items.Count - 1

                dd.Items(i).Attributes.Add("style", "color:" + dd.Items(i).Text)

  4. Eyup
    Eyup avatar
    3387 posts

    Posted 20 Nov 2017 Link to this post

    Hello Michael,

    I've already replied to your query in your formal support ticket about the same matter. I suggest that we continue our technical conversation on the mentioned thread.

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top