如何突出asp.net中dropdownlist的第一个值 [英] how to highlight first value from dropdownlist in asp.net

查看:58
本文介绍了如何突出asp.net中dropdownlist的第一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中突出显示Dropdownlist中的第一个值,



我在Dropdownlist中绑定一些值。我需要一个突出显示(不同颜色)第1项下拉列表。怎么做。任何人都可以帮助我。谢谢

how to highlight first value from Dropdownlist in asp.net,

I bind a some values in my Dropdownlist .i need a highlight(different colour) 1st item Dropdownlist .How to do it.any one can help me. Thank You

推荐答案

试试这个



Try this

<style type="text/css">

       option.red
       {
           background-color: red;
       }
       option.blue
       {
           background-color: blue;
       }
       option.white
       {
           background-color: white;
       }

   </style>







<select>
            <option value="item 1" class="red">Item 1</option>
            <option value="item 2" class="blue">Item 2</option>
            <option value="item 3" class="white">Item 3</option>
        </select>





这是理智的你的意思寻找



is this sane u r looking for


尝试以下代码



Try the below code

dropdownlist1.Items[0].Attributes.Add("style","background-color:Red");





希望这有帮助......



hope this helps...


您好,



请根据需要设置背景颜色。并且基于选项选择,您还必须更改下拉列表的背景颜色(选择)。因为选项和选择控件是不同的。所以在javascript / Jquery的帮助下你可以管理BG颜色的选项和选择框。



希望这会有帮助
Hi,

Please set background color as you want in option. and based on option selection you have to change background color of dropdown(select) also. Because option and select control are different. So with the help of javascript/Jquery you can manage BG color of option and select box.

Hope this will help


这篇关于如何突出asp.net中dropdownlist的第一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆