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

List Controls: List Box and Drop Downlist

ASP.Net provides the controls: drop-down list, list box, radio button list, check box list and bulleted list. These control let a user choose from one or more items from the list. List boxes and drop-down list contain one or more list items. These lists could be loaded either by code or by the ListItem Collection Editor. Basic syntax for list box control: <asp:ListBox ID="ListBox1"        runat="server"        AutoPostBack="True"        OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"> </asp:ListBox> Basic syntax for a drop-down list control: <asp:DropDownList ID="DropDownList1"       runat="server"       AutoPostBack="True"       OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> </asp:DropDownList>

Sql CharIndex Function

The CHARINDEX  function returns the starting position of the specified expression in a character string. Example: Search for "t" in string "DotNetReceipe", and return position: SELECT CHARINDEX( 't' , 'DotNetReceipe' ) AS Position;