PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3. <CodeSnippet Format="1.0.0">
  4. <Header>
  5. <SnippetTypes>
  6. <SnippetType>Expansion</SnippetType>
  7. </SnippetTypes>
  8. <Title>Get the value of a lookup field from a list item</Title>
  9. <Author>Ayman El-Hattab http://ayman-elhattab.blogspot.com
  10. </Author>
  11. <Description> </Description>
  12. <HelpUrl>http://SPCodeSnippets.codeplex.com</HelpUrl>
  13. <Shortcut>
  14. </Shortcut>
  15. </Header>
  16. <Snippet>
  17. <Declarations>
  18. <Literal Editable="true">
  19. <ID>FieldName</ID>
  20. <ToolTip>Field name</ToolTip>
  21. <Default>FieldName</Default>
  22. <Function>
  23. </Function>
  24. </Literal>
  25. <Literal Editable="true">
  26. <ID>lookupID</ID>
  27. <ToolTip>Lookup ID</ToolTip>
  28. <Default>lookupID</Default>
  29. <Function>
  30. </Function>
  31. </Literal>
  32. <Object Editable="true">
  33. <ID>fieldLookupValue</ID>
  34. <ToolTip>SPFieldLookupValue</ToolTip>
  35. <Default>fieldLookupValue</Default>
  36. <Function>
  37. </Function>
  38. <Type>SPFieldLookupValue</Type>
  39. </Object>
  40. <Literal Editable="true">
  41. <ID>lookupValue</ID>
  42. <ToolTip>Lookup value</ToolTip>
  43. <Default>lookupValue</Default>
  44. <Function>
  45. </Function>
  46. </Literal>
  47. <Object Editable="true">
  48. <ID>item</ID>
  49. <ToolTip>SPListItem</ToolTip>
  50. <Default>item</Default>
  51. <Function>
  52. </Function>
  53. <Type>SPListItem</Type>
  54. </Object>
  55. </Declarations>
  56. <Code Language="csharp"><![CDATA[
  57. SPFieldLookupValue $fieldLookupValue$ = new SPFieldLookupValue($item$["$FieldName$"].ToString());
  58. int $lookupID$ = $fieldLookupValue$.LookupId;
  59. string $lookupValue$ = $fieldLookupValue$.LookupValue;
  60. ]]></Code>
  61. </Snippet>
  62. </CodeSnippet>
  63. </CodeSnippets>