remove selected item from dropdownlist | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial remove selected item from dropdownlist

In this article I am going to explain how to remove the selected item from dropdownlist in using C#,


HTML Markup:
<asp:DropDownList ID="ddlItems" runat="server" AutoPostBack="True" CssClass="dropdownlist" onselectedindexchanged="ddlItems_SelectedIndexChanged">
         <asp:ListItem Selected="True" Value="-1">--Select Item--</asp:ListItem>
            <asp:ListItem>Item 1</asp:ListItem>
            <asp:ListItem>Item 2</asp:ListItem>
            <asp:ListItem>Item 3</asp:ListItem>

            <asp:ListItem>Item 4</asp:ListItem>
            <asp:ListItem>Item 5</asp:ListItem>             

Write the below given code on SelectIndexchanged event of Dropdownlist

C# code:
protected void ddlItems_SelectedIndexChanged(object sender, EventArgs e)
        ddlItems.Items.FindByText(ddlItems.SelectedItem.Text).Enabled = false;
    } Code:
Protected Sub ddlItems_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlItems.SelectedIndexChanged
        ddlItems.Items.FindByText(ddlItems.SelectedItem.Text).Enabled = False
    End Sub

Post a Comment

Great tutorial. Thanks for sharing :)

Thanks for your valuable feedback.... Keep visiting for more article.

Its very interesting and informative post
Thanks for sharing keep up the Good work

Thanks for your valuable feedback. Keep visiting for more articles.

Nice Information,, Thanks for share



Contact Form


Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget