In
this article I am going to explain how to remove the selected item from
dropdownlist in asp.net using C#, VB.net
In
the previous article I have explained how to show the data in Gridview clientside using Jquery, Json and Ajax and how to populate Category and Sub-categoryin single dropdownlist in Asp.net.
Implementation:
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>
</asp:DropDownList>
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;
}
VB.net
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
Great tutorial. Thanks for sharing :)
ReplyDeleteThanks for your valuable feedback.... Keep visiting for more article.
DeleteGood
Deletethanku for great informations
ReplyDeleteIts very interesting and informative post
ReplyDeleteThanks for sharing keep up the Good work
Thanks for your valuable feedback. Keep visiting for more articles.
DeleteNice Information,, Thanks for share
ReplyDeleteThanks for your valuable feedback. keep visiting.. Check my new post http://www.aspmantra.com/2017/10/custom-pager-in-asp.net-mvc-pagedlist-aspmantra.html
DeleteNice and useful article
ReplyDeleteCreate info
ReplyDeletethank you
I can understand it.
ReplyDeleteGood article, keep sharing with us.
ReplyDeletebahut hi badhiya information, thanks for sharing
ReplyDeleteReally helpful codes you shared with us.. update with more pls
ReplyDeletethanks for your useful information.I appreciate your work.
ReplyDeletenice article thanks!
ReplyDeleteVERY GOOD tutorial. Thanks U for sharing
ReplyDeleteReally helpful codes you shared with us
ReplyDeleteReally helpful codes you shared with us.. update with more pls
ReplyDeleteThanks for the detailed article, Would love to see more of these.
ReplyDeleteTHank you for this great article....
ReplyDeleteThank you for this information. i was looking for it and here i found something similar....
ReplyDeleteExcellent post, it was very helpful. Would like to see more stuff like this. Good Regards Clashmod.
ReplyDeleteThanks for the detailed article on this topic. I would like to see more such awesome articles from you.
ReplyDeleteThanks for the detailed article on this topic. I would like to see more such awesome articles from you.
ReplyDeleteHi, Thank you for this info post keep share with us.
ReplyDeleteThank you so much for sharing it !!
ReplyDelete