Live Chat Icon For mobile
Live Chat Icon

How can an ListItem in the ListControl can be avoided from being displayed but it must remain in the collection?

Platform: ASP.NET| Category: Custom Controls

In ASP.NET 2.0 List by setting Enabled=’False’ to the individual list item, entries avoids it from being displayed but it remains in the collection.

It can be coded as below.


<asp:ListBox ID='ListBox1' runat='server' >
	<asp:ListItem   Enabled='False'>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:ListItem>Item 6</asp:ListItem>
</asp:ListBox>

Here Item1 remains in the collection but will not be displayed.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.