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.

  • 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? May 14, 2012 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.

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

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.