Here is the C# code to get the Lookup field value:
Here is the C# code to Set the Lookup field value:
SPList list = web.Lists[ "Tasks" ]; SPListItem existingBranch = list.Items[0]; SPFieldLookupValue group = new SPFieldLookupValue(existingBranch[ "Food Coupons" ].ToString()); string lookedUpItemTitle = group.LookupValue; |
SPList list = web.Lists[
"Tasks"
];
SPListItem newBranch = list.Items.Add();
newBranch[
"Title"
] =
"New lookup"
;
SPFieldLookupValue newValue =
new
SPFieldLookupValue(14,
"Test"
);
newBranch[
"Sample"
] = newValue;
newBranch.Update();
No comments:
Post a Comment