下拉列表显示一个字段 [英] Drop downlist disply one field

查看:69
本文介绍了下拉列表显示一个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个由两个列表项A和B组成的下拉列表,现在我只想显示字段A,但不显示字段B.我该怎么做.

请帮忙

谢谢

Hi,

I have a drop down list which consist of two list item A and B, now i want to display field A only but Not B how i do it.

Please help

Thanks

推荐答案

<select id="mySelect">
    <option value="A">Option A</option>
    <option value="B" style="display:none;">Option B</option>
</select>



如果它是带有listitem的asp:DropDownList,则不能设置visible ="false"或其他任何内容.您将必须重新绑定列表,而不带选项"B".
或者,您也可以使用javascript(jquery)实现相同的功能:



If it''s a asp:DropDownList with listitem''s you cant''t set visible="false" or anything. You will have to rebind the list without option "B".
Or you can achieve the same with javascript (jquery):

function hideB() {


(' #mySelect').find(' option [value ="B"]') .隐藏(); }
('#mySelect').find('option[value="B"]').hide(); }




尝试这样..

Hi,

try like this..

DropDownList1.Items[1].Attributes.Add("style","display:none");



希望它能起作用.



hope it works.


这篇关于下拉列表显示一个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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