Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm creating a page showing all items from a list. I have enabled versioning for that list. So I want to show the list of all items, even pending items, when a user with contribute permissions is logged in.

DataTable dtserviceDetailsItems = serviceDetailsList.Items.GetDataTable();

How to do that?

share|improve this question

1 Answer 1

Got the solution :)

            using (SPSite site = new SPSite(siteId))
                thisWeb = site.OpenWeb();
                SPList serviceDetailsList = thisWeb.Lists["Service Details"];
                if (serviceDetailsList.Items.Count > 0)
                    DataTable dtserviceDetailsItems = serviceDetailsList.GetItems().GetDataTable();
                    dtserviceDetailsItems.Columns.Add("Profile", typeof(string));
                    dtserviceDetailsItems.Columns.Add("Topic", typeof(string));
                    gvServices.DataSource = GetSortedData(dtserviceDetailsItems, gvSortExpression, gvSortDirection);

using SPSecurity.RunWithElevatedPrivileges(delegate() {}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.