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

How to edit a column name in Sharepoint ?When O rename a column I can't get by the code to column name.

           if (properties.List.Title == "Wpisy")
       {
           SPList lstOtherList = properties.Web.Lists["Szczegoly"];
           SPListItem item = lstOtherList.AddItem();

           item["Kontrakt"] = properties.AfterProperties["Kontrakt1"];
           item["Pracownik"] = properties.AfterProperties["Pracownik1"];
           item["Dzien"] = properties.AfterProperties["DzienStart"];

           item.Update();
       }
       base.ItemAdding(properties);

I must change a name for columns, and this is works, but i don't want to always build a new list from the begining.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Every column in SharePoint has 3 names:

  • InternalName (just called Name in <Field> and <FieldRef> elements)
  • StaticName
  • DisplayName (called Title in SPField)

InternalName can't be changed after field has been created
StaticName can be changed through code
DisplayName can be changed through code/UI

When accessing data/fields you should always use ID (often from SPBuiltInFieldId), InternalName (often using GetFieldByInternalName and then ID, but also directly as when accessing AfterProperties) or StaticName (often using TryGetFieldByStaticName and then ID)

share|improve this answer
    
Yes, but i don't want to use CALM. Maybe it is more easy use ? –  Grzegorz Z Oct 15 '12 at 18:42
    
But how can I write theme ? In the Label, or console ? –  Grzegorz Z Oct 16 '12 at 14:38

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.