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 have created a list in SharePoint 2010, initially had the columns - Title , Mobile and Email Id. Then I used a grid view (Visual web part) to display these fields.

Later I changed the field Title to Name and Email Id to Email. I tried accessing these fields in the grid view with new fields , however it doesn't fetch anything, only the old column name is still working !!

In list I have all the new names !!

What will be the reason !!

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

The point is that you're changing only title of the field, while the column internal name remains unchanged. This behavour is intended, overwise your programmatic functionality may broke down if user accidentaly changes the field title. Also, fields titles could be localized.

So, if you need to change field internal name, then probably the easiest way to do it will be to recreate the field.

Btw, actually you can refer field by it's title, if it is acceptable for you (so you don't expect users to change field title and you don't expect that your portal could be multilingual):

Finally, cannot resist to mention: for OOTB fields, like "Title", I would prefer to use SPBuiltInFieldId class for fetching it's Guid. For example:

 SPListItem item = ...;
 item[SPBuiltInFieldId.Title] = "New title";
 item.Update();
share|improve this answer
    
That's great!! So I can even change the internal name also right !! Thanks !! –  Jithu Nov 3 '11 at 11:16
add comment

You would have changed the display name (Title property), not the internal name (InternalName property). Fields are usually referenced by their internal names when using the API in SharePoint, although there are quite a few places where both the display name and title can be used. You must use the original name of the column, or recreate the field with the name desired internal name.

See the SPField class for more information.

share|improve this answer
    
Thanks Dan for this info !! I was not aware of that !! –  Jithu Nov 3 '11 at 11:16
add comment

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.