如何设置Lookup字段的值, 首先我们同样需要了解SPFieldLookupValueCollection和SPFieldLookupValue, 这2个类的原理和之前所讲解到SPFieldUserValueCollection一样,这里就不多讲解
1 /// <summary> 2 /// Convert dropdownList value to SPFieldLookupValue 3 /// </summary> 4 /// <param name="dropdownList">DropDownList Control</param> 5 /// <returns>SPFieldLookupValue</returns> 6 private SPFieldLookupValue setLookupValue(DropDownList dropdownList) 7 { 8 SPFieldLookupValue lookupValue = new SPFieldLookupValue(Convert.ToInt32(dropdownList.SelectedItem.Value), dropdownList.SelectedItem.Text); 9 return lookupValue; 10 }