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 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)));
 }
share|improve this question
    
Refer to : sharepoint.stackexchange.com/questions/30414/… –  Louis Oct 17 '12 at 10:24
add comment

3 Answers

up vote 2 down vote accepted

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
        }
share|improve this answer
    
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
    
Thanks Louis, corrected that in my answer! –  Arsalan Adam Khatri Oct 17 '12 at 10:41
add comment

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

share|improve this answer
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
add comment

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);
}
share|improve this answer
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.