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've created a custom content type and a list definition and list instance based on it. In a web part, I add an SPListItem to the list, set its field values, and then call item.Update().

However, when I browse to the AllItems.aspx view of the list, the values for that item are incorrect. Two of the fields are just empty, and two have incorrect values (as if the field values got shifted somehow - the value for field #3 shows up in field #2, etc).

Here's what's frustrating, though: the values are being stored in the contentdb correctly (I think). If I open the detail view for the item, all the values shown are correct.

Why would my view be showing the wrong values? I've checked my list schema over and over for matching field names, but I just don't seem to be able to figure out what's going on.

Update: One of the fields in the content type used to define the list is a lookup column. If I remove it from the list view, the other values are rendered correctly. What's the deal with that?

Update 2: looks like having non-alphanum chars in the Name property of a Field is what's causing this. I changed the field from something like "Company.AppName - FieldName" to "Company.Appname.Fieldname", and it failed in the same way. I then changed it to "CompanyAppnameFieldname" and it worked fine.

share|improve this question
    
Do you by any chance have any custom XSLT on the view? If you create a new view from scratch with the same columns what do you see? If you rearrange the order of the columns in AllItems what happens? If you create a new list in the browser using that provisioned content type, does it work? –  Derek Gusoff May 14 '12 at 22:49

1 Answer 1

Well, I hate this kind of thing where I get something working only moments after posting a question, but in this case it seems that you can't use anything other than alphanum characters in the Name property of an SPField. I changed my name as indicated in my second update above (from "Company.Appname - Fieldname" => "Company.Appname.Fieldname" => "CompanyAppnameFieldname") before getting it to work, and with no other changes.

I didn't know that there was a restriction against {'.', ' ', '-'} in SPField.Name, but there apparently is. This is unfortunate because these names were generated by the Visual Studio item templates.

share|improve this answer
    
If this solved your original question, please mark this as the Accepted answer to help other with the similar problem. Thank You! –  Benny Skogberg MCSA Jul 23 at 14:45

Your Answer

 
discard

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.