Click here to Skip to main content
15,910,130 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

There are two way to achive this

First in Aspx page


XML
<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>


Second in CS page

C#
foreach (ListItem i in Sex.Items)
            {
                i.Enabled = true;
            }
 
Share this answer
 
Comments
Member 10690248 17-Apr-14 1:28am    
tnx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900