System.Web.UI.WebControls Namespace CheckBoxList Class
Initializes a new instance of the CheckBoxList class.
[ VB ]
Public Sub New ( )
[ C# ]
public CheckBoxList ( );
[ C++ ]
public: CheckBoxList ( );
[ JScript ]
public function CheckBoxList ( );
Use this constructor to initialize a new instance of the CheckBoxList control.
The following example demonstrates how to initialize a new instance of the CheckBoxList class at run time.
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ArrayList myListItems = new ArrayList ( );
myListItems.Add ( "Item 1" );
myListItems.Add ( "Item 2" );
myListItems.Add ( "Item 3" );
myListItems.Add ( "Item 4" );
myListItems.Add ( "Item 5" );
CheckBoxList myList = new CheckBoxList ( );
Page.Controls.Add ( myList )
myList.DataSource = myListItems;
myList.DataBind ( );
}
}
Sub Page_Load ( src As Object, e As EventArgs )
If Not IsPostBack Then
Dim myListItems As New ArrayList ( )
myListItems.Add ( "Item 1" )
myListItems.Add ( "Item 2" )
myListItems.Add ( "Item 3" )
myListItems.Add ( "Item 4" )
myListItems.Add ( "Item 5" )
Dim myList As New CheckBoxList ( )
Page.Controls.Add ( myList )
myList.DataSource = myListItems
myList.DataBind ( )
End If
End Sub |
|
C# |
VB |
CheckBoxList Members