views:

561

answers:

4

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
A: 

You're looking for ["LinkTitle"] or ["Name"] - most likely the former.

Andy Mikula
I am looking for the value in the column "Title"...
Oliver S
Is this a task list? A document list?
Andy Mikula
Thats what he's saying Oliver. Every field has an Internal name (that never changes) and a Display name. The field you see as "Title" may have an internal name of LinkTitle or Name - check out Knights code or the codeplex sharepoint manager
Ryan
A: 

If you have two items that have the same display name but with different internal names then SharePoint most likely added elements to differentiate the fields. I would put a break point on the list item and look through the xml code for the item (copy paste it into VS). Then you may be able to see how the fields are different.

If that doesn't work then store the GUID and use that instead.

webwires
+2  A: 

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();
knight0323
A: 

Have you tried item.Title?

dahlbyk