使下拉列表项目不可选 [英] make drop down list item unselectable

查看:182
本文介绍了使下拉列表项目不可选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有具有生成报告的几个选项一个DropDownList。基于帐户的类型用户具有它应该是可见的,但是不能选择(作为激励他们升级)某些选项。

I have a dropdownlist which has several options for generating reports. Based on the type of account the user has certain options which should be visible but not selectable (as an incentive for them to upgrade).

我想知道是否有人知道的一种方式做到这一点。

I was wondering if anyone knew of a way to accomplish this.

权限已经到位,我只是需要做某些项目不可选的援助。

The permissions are already in place i just need assistance with making certain items unselectable.

任何帮助将非常AP preciated。

any help would be much appreciated.

肖恩

推荐答案

不知道,如果你还在寻找这个答案?

Not sure if you are still looking for an answer for this?

马克·雷德曼的回答是伟大的,如果你可以定义aspx页面选择列表,但是如果你的绑定下降下拉列表中动态显然,你不能。

Mark Redman's answer is great if you can define the select list in the aspx page, however if you bind the drop down list dynamically obviously you cannot.

我用下面实现的结果你是后(不知道全浏览器的支持,但在IE的新版本的工作)取得了成功。

I had success using the following to achieve the result you are after (not sure on full browser support but works in newer versions of IE)

foreach ( ListItem item in dropdownlist.Items )
{
    if ( [item should be disabled condition] )
    {
        item.Attributes.Add( "disabled", "disabled" );
    }
}

这会使您禁用的元素变灰。

This will render your disabled elements greyed out.

这篇关于使下拉列表项目不可选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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