Tuesday, January 8, 2013

Disable/enable Dropdownlist in asp.net using c#.net

In this post i will show how to disable a drop down in asp.net using c#.net.Here i have used two drop down lists to perform this task. Whenever  the first drop down  selected then another drop down will be disabled
Aspx:
<asp:DropDownList ID="ddloption" runat="server" onselectedindexchanged="ddloption_SelectedIndexChanged" 
       AutoPostBack="True">
<asp:ListItem>Please select</asp:ListItem>
<asp:ListItem>Hyderabad</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlcode" runat="server" 
AutoPostBack="True">
<asp:ListItem>Please select</asp:ListItem>
</asp:DropDownList>
Code :
protected void ddloption_SelectedIndexChanged(object sender, EventArgs e)
{
ddlcode.Enabled = false;
}
The above code is for drop down selected index event for first drop down list

Post a Comment

Bel