Ads

Saturday, 23 March 2013

C# code to add Choice Field column to a SharePoint List Programmatically

/* get the newly added choice field instance */
SPFieldChoice chFldGender = (SPFieldChoice)lst.Fields["Gender"];
/* set field format type i.e. radio / dropdown */
chFldGender.EditFormat = SPChoiceFormatType.Dropdown;
/* set the choice strings and update the field */
chFldGender.Choices.Add("Male");
chFldGender.Choices.Add("Female");
chFldGender.Update();
/* finally update list */
lst.Update();

No comments:

Post a Comment

Ads