Friday, August 3, 2012

some elementary asp:dropdownlist manipulations

This will add an empty ListItem at the end of an asp:dropdownlist.

POC.DataBind();
POC.Items.Add(new ListItem("",""));

 
 

This will add an empty ListItem at the beginning of an asp:dropdownlist and make it the default selection.

POC.Items.Add(new ListItem("",""));
POC.Items.Insert(0, new ListItem("", ""));
POC.Items[0].Selected = true;

No comments:

Post a Comment