Methods of List Controls in Asp.Net

Methods of List Controls

We have explained the properties of ListBox, DropDownList, CheckBoxList, RadioButtonList and BulletedList controls in the previous topic. Some of the commonly used methods of these controls are:

Items.Add() Metodu

It is used to add a new element to the list.

ListBox1.Items.Add ( "Ankara" ) ;

Items.Remove() Metodu

It is used to delete an element in the list.

DropDownList1.Items.Remove( "Ankara" ) ;

Items.Clear() Metodu

Clears all the elements of the list.

DropDownList1.Items.Clear ( ) ;

 

asp.net list type controls and their methods, using methods of dropdownlist checkboxlist radiobuttonlist listbox, properties of listbox, examples methods, list element addition, deletion and removal

EXERCISES

Adding Selected Elements in CheckBoxList to BulletedList

All elements selected in the CheckBoxList1 control will be added to the BulletedList1 control:

for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
    if (CheckBoxList1.Items[ i ].Selected)
BulletedList2.Items.Add(CheckBoxList1.Items[i].Text);
}

 



COMMENTS




Read 1157 times.

Online Users: 11401



methods-of-list-controls