Skip to main content

Add item How to set a lookup field by code c# ?? :(code

I have a list in sharepointSharePoint and it contains a lookup field .... howNow I want to insert an item to this field by code ,,list,because i have a problem in it and i but don't know how to work with the lookup field. I tried the following code but no item is added

SPFieldLookupValue gov = new SPFieldLookupValue(gv.SelectedValue); items["gov_name"] = gov.LookupValue; items.Update();

SPFieldLookupValue gov = new SPFieldLookupValue(gv.SelectedValue);
items["gov_name"] = gov.LookupValue;
items.Update();

Add item to lookup field by code c# ?? :(

I have list in sharepoint and it contains lookup field .... how to insert an item to this field by code ,,,because i have a problem in it and i tried the following code but no item is added

SPFieldLookupValue gov = new SPFieldLookupValue(gv.SelectedValue); items["gov_name"] = gov.LookupValue; items.Update();

How to set a lookup field by c# code

I have a list in SharePoint and it contains a lookup field. Now I want to insert an item to this list, but don't know how to work with the lookup field. I tried the following code but no item is added.

SPFieldLookupValue gov = new SPFieldLookupValue(gv.SelectedValue);
items["gov_name"] = gov.LookupValue;
items.Update();
Tweeted twitter.com/#!/StackSharePoint/status/323207859313725441
Source Link
NOOR
  • 53
  • 1
  • 1
  • 6

Add item to lookup field by code c# ?? :(

I have list in sharepoint and it contains lookup field .... how to insert an item to this field by code ,,,because i have a problem in it and i tried the following code but no item is added

SPFieldLookupValue gov = new SPFieldLookupValue(gv.SelectedValue); items["gov_name"] = gov.LookupValue; items.Update();