Software Technology Tips

Choice fields are often used within SharePoint lists to display choice options like Gender, Status, etc and these choice options can be displayed using Radio Button and Dropdown formats.
 
Provided below is a code sample in C#.Net which describes the creation of a choice field programmatically using SharePoint API.
 
/* 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();


Related Tags:

Sharepoint, C#

Author: Kaushik Mohanty

Related Pages

  • SharePoint Development India
  • SharePoint Application Projects

SharePoint

Let us Connect!

iso 9001 QA25 Red Herring STPI D&B Fastest Growing SME 2013 Award zinnov Nasscom

copyright (c) Mindfire Solutions 2007-2014. Login