1

How can I see the values, and how can I call them from code?

When I'm calling like this, what sort of name type am I using?:

 SPWeb witryna = SPContext.Current.Web;
 SPListItemCollection listaDniNaProjektDropDownList = witryna.Lists["Szczegoly"].Items;
 foreach (SPListItem oListaDniUrlopu in listaDniNaProjektDropDownList)
 {
    index = oListaDniUrlopu["Pracownik"].ToString().IndexOf("#");
    DropDownList1.Items.Add((oListaDniUrlopu["Pracownik"].ToString().Substring(index + 1)));
 }
3

In addition to Hugh Wood's answer... When you are using fields like this:

oListaDniUrlopu["Pracownik"]

Here "Pracownik" is Internal Name of the field, and you can have access to Display Name, Internal Name and Static Name like this:

SPList myList = witryna.Lists["Szczegoly"];

foreach (SPField field in myList.Fields)
        {
            string internalName = field.InternalName;
            string staticName = field.StaticName;
            string displayName = field.Title; //Courtesy: Louis
        }
  • Thanks A Lot :) :) Whats a food description :) You Are Great :) – Grzegorz Z Oct 17 '12 at 10:24
  • The field's display name is (more exactly) SPField.Title – Louis Oct 17 '12 at 10:24
4

To be completely correct:

If you use

oListaDniUrlopu["Pracownik"]

then Sharepoint looks up in ALL of the three Names

First it looks for a field with a matching InternalName. If there is none, then it looks for a Field with a maching DisplayName, and if there is even nothing, then finally looks for a Field with a matching StaticName.

You could look this up in the indexer Function of the SPListItem Object using a Decompiler like IlSPy:

SPField sPField = this.GetFieldByInternalName(strName, false);
if (sPField == null)
{
    sPField = this.GetFieldByDisplayName(strName, false);
}
if (sPField == null)
{
    sPField = this.TryGetFieldByStaticName(strName);
}
2

Display name is what you see on the user interface.

Internal name is the non changeable name and is unique, used as an identifier for the field.

And well Static name is a changeable version of Internal name and yeah read msdn for this one

  • 1
    Is the StaticName practically changeable? I would not risk to change it.... – Steve B Oct 17 '12 at 8:09
  • If it isn't an external datasource then it doesn't matter, but you can't change for external datasources. Just use static name for SP standard fields as practice as this won't change. I also tend to use it for my own custom fields to where appropiate. – Hugh Wood Oct 17 '12 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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