R – Get Real Title from SharePoint Lists

listnetsharepoint

Hi I am querying the Sharepoint Lists using the Sharepoint Library in .net. I noticed that there is more than one title field. How can I get the user defined title field?

 SPListItem item = myItemCollection[i];
 item["Title"] <- provides me the wrong title field

Is this a known issue, any work around? Thanks

However if I go into my list settings and rename the column from Title to Article. And do the following it works:

 SPListItem item = myItemCollection[i];
 item["Article"] <- provides me the wrong title field

Best Answer

Run this in a console application. More than likely your problem is related to difference in Display and Internal name as mentioned above. Something to note: even when you create a custom list and rename the default "Title" field the internal name never changes from "Title".

using (SPSite siteCollection = new SPSite("~~~~ Your site URL here ~~~~"))
{
    using (SPWeb site = siteCollection.RootWeb)
    {
        foreach (SPField f in site.Lists["~~~~ Your list name here ~~~~"].Fields)
        {
            Console.WriteLine(f.InternalName + " | " + f.Title);
        }
    }
}

Console.ReadLine();