Generally SharePoint choice field will be used to display choice options.Choice field can be displayed using Drop-Down Menu,Radio Buttons and Check boxes.
Using below code we can add the values in choice field SharePoint List programmatically in .I have used C# and SharePoint API in this code.
using (SPWeb web = SPContext.Current.Site.OpenWeb())
{
//Get the list
SPList list = web.Lists["Test List"];
//Get the Choice filed using SPFieldChoice
SPFieldChoice
choicefield = (SPFieldChoice)list.Fields["MyChoice"];
web.AllowUnsafeUpdates = true;
//Add some values
choicefield.Choices.Add("Test 4");
choicefield.Choices.Add("Test 5");
//Update the column for the changes to take affect
choicefield.Update();
web.AllowUnsafeUpdates = false;
}
No comments:
Post a Comment