asp.net.ph

DropDownList Constructor

System.Web.UI.WebControls Namespace   DropDownList Class


Initializes a new instance of the DropDownList class.

[ VB ]
Public Sub New ( )

[ C# ]
public DropDownList ( );

[ C++ ]
public: DropDownList ( );

[ JScript ]
public function DropDownList ( );

Remarks

When using this constructor to instantiate a new instance of the DropDownList control, the ListItem and ListItemCollection classes are also used. The ListItem control stores the item content whereas the ListItemCollection allows it to be added to the DropDownList control.

Example

The following example demonstrates how to initialize a new instance of the DropDownList class.

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" );

      DropDownList myList = new DropDownList ( );
      Page.Controls.Add ( myList )
      myList.DataSource = myListItems;
      myList.DataBind ( );
   }
}
  C# VB

See Also

DropDownList Members Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note