We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


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.