/Main/SPALM.SharePointSoftwareFactory/Snippets/CSharp/SharePoint Software Factory 2010/ListItems/Get the value of a lookup field from a list item.snippet
Unknown | 63 lines | 63 code | 0 blank | 0 comment | 0 complexity | 38b7530e99e80a6a49b1bd11b6f0de0a MD5 | raw file
- <?xml version="1.0" encoding="utf-8"?>
- <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
- <CodeSnippet Format="1.0.0">
- <Header>
- <SnippetTypes>
- <SnippetType>Expansion</SnippetType>
- </SnippetTypes>
- <Title>Get the value of a lookup field from a list item</Title>
- <Author>Ayman El-Hattab http://ayman-elhattab.blogspot.com
- </Author>
- <Description> </Description>
- <HelpUrl>http://SPCodeSnippets.codeplex.com</HelpUrl>
- <Shortcut>
- </Shortcut>
- </Header>
- <Snippet>
- <Declarations>
- <Literal Editable="true">
- <ID>FieldName</ID>
- <ToolTip>Field name</ToolTip>
- <Default>FieldName</Default>
- <Function>
- </Function>
- </Literal>
- <Literal Editable="true">
- <ID>lookupID</ID>
- <ToolTip>Lookup ID</ToolTip>
- <Default>lookupID</Default>
- <Function>
- </Function>
- </Literal>
- <Object Editable="true">
- <ID>fieldLookupValue</ID>
- <ToolTip>SPFieldLookupValue</ToolTip>
- <Default>fieldLookupValue</Default>
- <Function>
- </Function>
- <Type>SPFieldLookupValue</Type>
- </Object>
- <Literal Editable="true">
- <ID>lookupValue</ID>
- <ToolTip>Lookup value</ToolTip>
- <Default>lookupValue</Default>
- <Function>
- </Function>
- </Literal>
- <Object Editable="true">
- <ID>item</ID>
- <ToolTip>SPListItem</ToolTip>
- <Default>item</Default>
- <Function>
- </Function>
- <Type>SPListItem</Type>
- </Object>
- </Declarations>
- <Code Language="csharp"><![CDATA[
- SPFieldLookupValue $fieldLookupValue$ = new SPFieldLookupValue($item$["$FieldName$"].ToString());
- int $lookupID$ = $fieldLookupValue$.LookupId;
- string $lookupValue$ = $fieldLookupValue$.LookupValue;
- ]]></Code>
- </Snippet>
- </CodeSnippet>
- </CodeSnippets>