0

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 !!

2 Answers 2

2

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();
1
  • That's great!! So I can even change the internal name also right !! Thanks !!
    – Jithu
    Nov 3, 2011 at 11:16
1

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.

1
  • Thanks Dan for this info !! I was not aware of that !!
    – Jithu
    Nov 3, 2011 at 11:16

Your Answer

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

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