Wednesday 18 July 2012

Bind lookup field data to the dropdownlist

Below code will help you to bind the lookup field data to the dropdown list.
if (spListItem["LookupField"] != null)
{
  SPFieldLookupValue spv = new   
  SPFieldLookupValue(spListItem["LookupField"].ToString());
  string lookupValue = spv.LookupValue;
  dropdownlist1.SelectedIndex = spv.LookupId;
 }
 To bind field values to the dropdownlist:
dropdownlist1.SelectedValue = spListItem["Field1"].ToString();