Guest User

Untitled

a guest
Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public static SPListItem GetItemById(string listname, int itemId)
  2. {
  3. String siteUrl = "http://sp:5872";
  4. SPSite spSite = new SPSite(siteUrl);
  5. SPList list = spSite.RootWeb.Lists[listname];
  6. SPListItem item = null;
  7. try
  8. {
  9. // init
  10. if (listname == null) { throw new Exception("SPList passed is null"); }
  11. item = list.GetItemById(itemId);
  12. }
  13. catch (Exception ex)
  14. {
  15. throw ex;
  16. }
  17. return item;
  18. }
Add Comment
Please, Sign In to add comment