This may be a bit too simple for most SharePoint developers but as I struggled to find the correct code I’ll drop it here, perhaps someone will get a hit if they search for the same thing…
What I wanted to achieve was to have a DropDownList which automatically retrieved its value from a SharePoint list. I wanted to I could have written a foreach loop to solve this but I knew data binding was the way to go. Include the code below in your Page_Load method and the list will be populated.
using (SPSite site = new SPSite("http://devserver/somesite"))
using (SPWeb web = site.OpenWeb())
SPList list = web.Lists["Departments"];
cboDepartment.DataSource = list.Items;
cboDepartment.DataValueField = "Title"; // List field holding value
cboDepartment.DataTextField = "Title"; // List field holding name to be displayed on page