I know that I have to use

SPSite site = new SPSite("SPsite Path");
SPWeb web = site.OpenWeb();
SPList contacts = web.Lists["Listname"];

if I need to get content of a List, but how do I read data from the pagecolumns of the page I am currently on?


                   foreach (SPListItem item in SPContext.Current.ListItem.ListItems)

                    output.Write(item[io] + "|" + io + "<br/>");


Does give me: 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39005A81DBCD88A1A24FA0B25F46F1AEC15500FAC7433996C57149A6320A1777FA6771|0

1 Answer 1


SPContext.Current.ListItem["ColumnName"] should do it

  • Does give me: 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39005A81DBCD88A1A24FA0B25F46F1AEC15500FAC7433996C57149A6320A1777FA6771|0 Commented Dec 7, 2011 at 15:03
  • Please post more of your code - in particulr where that io variable comes from, your result is that's the value of the Content Type column, and it's showing a content type of a custom Page Layout.
    – James Love
    Commented Dec 7, 2011 at 15:09
  • Argh.... i just want to access the Pages' columns which are inheriting from my custom Content Type.. The io is just an increasing int.. (started at 0)... ... I have a field called "Contact" in my Content Type and set this column through a field i added in my page-layout.. Now i want to read this field on the page i am in my wp. Commented Dec 7, 2011 at 15:16
  • Then have you tried SPContext.Current.ListItem["Contact"] ?
    – James Love
    Commented Dec 7, 2011 at 15:36
  • Ya this works... well.. the listing not but a'm okay with that solution. Thank you. Commented Dec 8, 2011 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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