GetChoiceFieldValues
this method find items of a Choice Field in a Sharepoint List
Source
public static List<string> GetChoiceFieldValues(this SPList list , string fieldName )
{
try
{
SPFieldChoice field = (SPFieldChoice)list.Fields[fieldName];
if (field == null || string.IsNullOrEmpty(fieldName))
{
return null;
}
List<string> ret = new List<string>();
foreach (string str in field.Choices)
{
ret.Add(str);
}
return ret;
}
catch (Exception ex)
{
return null;
}
}
Example
List<string> myitems = myspList.GetChoiceFieldValues("CountryNames");
Author: http://mb-seifollahi.ir
Submitted on: 25 mrt. 2013
Language: C#
Type: System.Collections.Generic.List<string>
Views: 4680