Skip to main content

The List Item Collections:




The ListItemCollection object is a collection of ListItem objects. Each ListItem object represents one item in the list. Items in a ListItemCollection are numbered from 0.
When the items into a list box are loaded using strings like: lstcolor.Items.Add("Blue") . then both the Text and Value properties of the list item are set to the string value you specify. To set it differently you must create a list item object and then add that item to the collection.
The ListItem Collection Editor is used to add item to a drop-down list or list box. This is used to create a static list of items. To display the Collection Editor select Edit item from the smart tag menu, or select the control and then click the ellipsis button from the Item property in the Properties window.
Common Properties of List Item Collection:
Property
Description
Item(integer)
A ListItem object that represents the item at the specified index.
Count
The number of items in the collection.
Common methods of List Item Collection:
Methods
Description
Add(string)
Adds a new item to the end of the collection and assigns the string parameter to the Text property of the item.
Add(ListItem)
Adds a new item to the end of the collection.
Insert(integer, string)
Inserts an item at the specified index location in the collection, and assigns the string parameter to the Text property of the item.
Insert(integer, ListItem)
Inserts the item at the specified index location in the collection.
Remove(string)
Removes the item with the Text value same as the string.
Remove(ListItem)
Removes the specified item.
RemoveAt(integer)
Removes the item at the specified index as the integer.
Clear
Removes all the items of the collection.
FindByValue(string)
Returns the item whose Value is same as the string.
FindByValue(Text)
Returns the item whose Text is same as the string.

Comments

Popular posts from this blog

Asp.net Component Model

ASP.Net Component Model: The ASP.Net component model provides various building blocks of ASP.Net pages. Basically it is an object model, which describes: ·          Server side counterparts of almost all HTML elements or tags, like <form> and <input>. ·          Server controls, which help in developing complex user-interface for example the Calendar control or the Gridview control. ASP.Net is a technology, which works on the .Net framework that contains all web-related functionalities. The .Net framework is made of an object-oriented hierarchy. An ASP.Net web application is made of pages. When a user requests an ASP.Net page, the IIS delegates the processing of the page to the ASP.Net runtime system. The ASP.Net runtime transforms the .aspx page into an instance of a class, which inherits from the base class Page of the .Net framework. Therefore, each ASP.Net page is an object and a...