Change color for each radlistbox item

3 posts, 0 answers
  1. Victor
    Victor avatar
    2 posts
    Member since:
    Apr 2012

    Posted 11 Apr 2012 Link to this post

    Hello, please I need help. I need to change a diferent color for each item that I already databinded in a radlistbox. It doesnt matter if it's from the server or the client side. In addition Can I make separations like a radgrid in a Radlistbox?Thank You
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2012 Link to this post

    Hi Victor,

    You can set different color for each RadListBoxItem in client side by setting different styles using its index as follows.

    JS:
    <script type="text/javascript">
        function OnClientLoad(sender, args)
         {
                sender.get_items().getItem(0).get_element().style.backgroundColor = "Red";
                sender.get_items().getItem(1).get_element().style.backgroundColor = "Blue";
                sender.get_items().getItem(2).get_element().style.backgroundColor = "Green";
         }
    </script>


    Try the following code to provide border for each RadListBoxItem.

    CSS:
    <style type="text/css">
       .RadListBox .rlbItem
        {
            border:1px solid Black !important;
        }
    </style>

    Hope this helps,

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Victor
    Victor avatar
    2 posts
    Member since:
    Apr 2012

    Posted 16 May 2012 Link to this post

    Thank you very much . It works.
Back to Top