Showing posts with label Get display list item display form. Show all posts
Showing posts with label Get display list item display form. Show all posts

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.