Posted By

rengber on 01/30/08


Tagged

simple N00b Trick


Versions (?)

Adding another item to a databound drop-down list.


 / Published in: C#
 

Stupidly simple, but I keep forgetting it.

  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  

You need to login to post a comment.