Sunday, October 12, 2014

SharePoint Quick tip - Get SharePoint list item display form details through code

We can get display form URL by appending “DispForm.aspx?ID=” with the URL by adding ID values at the end. We can get the form details byusing list item properties as shown the code below

using (SPSite currentSite = new SPSite(SiteURL))
{
    using (SPWeb currentWeb = currentSite.OpenWeb())
    {
        SPList currentList = currentWeb.Lists[
List Name];
        SPListItem currentListItem = currentList.Items[
ItemID];
        string displayForm= String.Concat(currentListItem.Web.Url, "/", currentListItem.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url, "?id=", currentListItem.ID.ToString());
    }
}


Hope this helps.

Share this

0 Comment to "SharePoint Quick tip - Get SharePoint list item display form details through code"

Post a Comment