如何启用DropDownlist的所有项目 [英] how to enable all items of a DropDownlist

查看:95
本文介绍了如何启用DropDownlist的所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码禁用下拉列表的项目



Dropdownlist.SelectedValue ="3";


Dropdownlist.SelectedItem.Enabled = false;


同样地,如果我们使用true,则启用它



但是我的问题是如何一次启用下拉菜单的所有项目

I''m using the following code to disablae an itema of a dropdownlist



Dropdownlist.SelectedValue = "3";


Dropdownlist.SelectedItem.Enabled = false;


simlarly if we use true it gets enabled



but my question is how to enalble all the items of a dropdown at a time

推荐答案

有两种方法可以实现这一目标

Aspx页面中的第一页


There are two way to achive this

First in Aspx page


<asp:DropDownList ID="Sex" runat="server">
            <asp:ListItem Selected="True" Value="Male" Enabled="true" >Male</asp:ListItem>
            <asp:ListItem Value="Female" Enabled="true">Female</asp:ListItem>
            </asp:DropDownList>



CS页面中的第二名



Second in CS page

foreach (ListItem i in Sex.Items)
            {
                i.Enabled = true;
            }


这篇关于如何启用DropDownlist的所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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