Adding another item to a databound drop-down list.


/ Published in: C#
Save to your folder(s)

Stupidly simple, but I keep forgetting it.


Copy this code and paste it in your HTML
  1. private void PopulateLookupData()
  2. {
  3. Lookup.SuburbDataTable subs = DALLookup.GetSuburbs();
  4. dropSuburb.DataSource = subs;
  5. dropSuburb.DataTextField = subs.SuburbColumn.ColumnName;
  6. dropSuburb.DataValueField = subs.SuburbIdColumn.ColumnName;
  7. dropSuburb.DataBind();
  8. dropSuburb.Items.Insert(0, new ListItem("Select a Suburb."));
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.