Wed, 2008-01-30 16:52 — carlos
this is how to populate a dropdown ASP.net 3.5 control with entity spaces in code behind
c#: (Item is tha name of my entity)
ItemCollection i = new ItemCollection();
i.LoadAll();
this.ddlItemType.DataSource = i;
this.ddlItemType.DataTextField = ItemMetadata.PropertyNames.Description;
this.ddlItemType.DataValueField = ItemMetadata.PropertyNames.ItemTypeID;
this.ddlItemType.DataBind();
if you add this after the databind it will add a list item at index zero (pre-selected)
ListItem li = new ListItem("select one ", "");
this.ddlItemType.Items.Insert(0,li);
Comments
Great website to generic