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

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

问题描述

我有一个下拉列表,它有几个生成报告的选项。根据帐户的类型,用户有某些选项应该是可见的,但不可选择(作为他们升级的动机)。



我想知道有没有人知道



权限已经到位,我只需要帮助,使某些项目不可选。



shawn

解决方案

不确定您是否仍在寻找答案?



Mark Redman的答案是非常好的,如果您可以在aspx页面中定义选择列表,但是如果您明确地绑定下拉列表,您将无法。



我已经成功使用以下功能来实现您以后的结果(不确定是否支持完整的浏览器,但适用于较新版本的IE)

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

这将使您的残疾元素变灰。 p>

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.

any help would be much appreciated.

shawn

解决方案

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

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.

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天全站免登陆