
368
CHAPTER 11 Building a Custom gloBal navigation solution
This provides you with quick access to the various underlying GUIDs of the elds in the list. For exam-
ple, if you need the GUID for the Order eld, you can access it simply by typing Lookup.FieldGuids.
MenuItem.Order. The GUIDS were all dened in the list denition schema.
Enhancing the ListHelper Class
The ListHelper class is meant to consist of common functionality related to SharePoint lists.
One common need when reading list item data from SharePoint is taking the non-strongly-typed
field data and casting it to the expected data type. Now add a few such helper methods to the
ListHelper class.
1. In Visual Studio, under the Shared folder, open the ListHelper.cs le.
2. Add the following code to the end of the class denition:
public static SPFieldMultiChoiceValue GetMultiChoice(SPListItem item,
Guid fieldId)
{
return new SPFieldMultiChoiceValue(
item[Lookup.FieldGuids.MenuItem.AutoPopulate] as string);
}
public static bool GetBooleanValue(SPListItem item, Guid fieldId)
{
return Convert.ToBoolean(item[fieldId]);
}
public static string GetStringValue(SPListItem item, Guid fieldId)
{
return item[fieldId] as string;
}
public static int GetIntValue(SPListItem item, Guid fieldId)
{
return Convert.ToInt32(item[fieldId]);
}
public static decimal GetDecimalValue(SPListItem item, Guid fieldId)
{
return Convert.ToDecimal(item[fieldId]); ...