Get the First & Last ListItem in Sharepoint List

后端 未结 2 1727
小鲜肉
小鲜肉 2021-02-20 17:08

On a pageLoad event I want to go to two different SharePoint Lists and get the first ListItem from one list and an the last ListItem in another. I don\'t know any o

2条回答
  •  野的像风
    2021-02-20 17:31

    You can try this to get the last itemID

    SPWeb web = SPContext.Current.Web;
                SPList List = web.Lists[ListName];
    
                int itemId = List.Items[List.ItemCount - 1].ID;
    

    Regards!

提交回复
热议问题