Skip to content

Change SPList.Title – no effect

September 13, 2012

When you try to change the Title of an SPList programmatically, you may see that your code executes without error but the Title of the list is not changed. I faced this problem when I was trying to change the Title from a console application where the SPContext did not exists.

I found the solution in this blog: http://www.sharepointblues.com/2011/11/14/splist-title-property-spfield-displayname-property-not-updating/

It turned out, that the CurrentUICulture of the SPWeb where your list is located MUST be the SAME as the CurrentUICulture of the thread where from you are updating the Title.

So now I use the following code to update a List’s Title:

private void UpdateListTitle(SPList list, string title)
{
	CultureInfo ci = Thread.CurrentThread.CurrentUICulture;
	try
	{
		if (SPContext.Current == null)
		{			
			Thread.CurrentThread.CurrentUICulture = new CultureInfo((int)list.ParentWeb.Language);
		}
	
		// change list's title
		list.Title = title;
		list.Update();		
	}
	finally
	{
		if (SPContext.Current == null)
		{
			Thread.CurrentThread.CurrentUICulture = ci
		}
	}
}
Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: