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!

privacy
iso 9001 QA25 Nasscom Red Herring zinnov STPI iso 27001

copyright (c) Mindfire Solutions 2007-2013. Login