Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using the Publishing feature of SharePoint. I have a custom Content Type that inherits from the ArticlePage Content Type, and is bound to the Pages list of a given site. My custom Content Type uses a custom display name for one of the columns. When I'm querying the Page list and iterating over the items using a repeater, accessing my custom column with

((Microsoft.SharePoint.SPListItem)Container.DataItem)["CustomDisplayName"]

I get an error:

Column 'CustomDisplayName' does not exist. It may have been deleted by another user.

If I use the internal name it works fine. I have verified that the given page has my custom Content Type, and I have verified that my custom Content Type lists the column with my custom display name.

Client code expects there to be a 'CustomDisplayName' column but it doesn't know if the 'CustomDisplayName' column overrides a base column or defines a new. E.g. "CustomPreamble" may override the ArticlePage's Preamble column, or it may reference some other column, hence I cannnot use "Preamble" to access it.

Any clues as to what's going on?

share|improve this question
    
You mention the internal name does work, so why not use that instead? I always prefer internal name or ID, since the displayname can be subject to changes. –  Jasper Oct 10 '12 at 8:42
    
The custom Content Type's "CustomDisplayName" column isn't necessarily always based on the same default column. Example: "MyCustomPreamble" may or may not use the ArticlePage's Preamble column. The client code only knows there's a "MyCustomPreamble" column. I'll update my question with those details. –  claesv Oct 10 '12 at 8:47
    
Ok. Tried the Get options? Like SPFieldCollection.GetField or SPFieldCollection.ContainsField on the content type object? –  Jasper Oct 10 '12 at 8:55
    
I'm iterating over SPListItems so that won't help. I printed out all the field name and the Display Name (Field.Title) isn't my custom name, but rather the default (static) name. It appears that fetching items using SPQuery and SPList.GetItems screws things up. –  claesv Oct 10 '12 at 9:25
    
While investigating further I discovered some oddities - see here sharepoint.stackexchange.com/questions/47553/… –  claesv Oct 10 '12 at 11:24
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.