I am using the following code to hide all WebParts in a page.

 string siteUrl = "http://site";
 SPSite site = new SPSite(siteUrl);
 SPWeb web;
 web = site.RootWeb;
 web.AllowUnsafeUpdates = true;
 Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null;
 mgr = web.GetLimitedWebPartManager("pages/test.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.User);
 mgr.Web.AllowUnsafeUpdates = true;
 foreach (System.Web.UI.WebControls.WebParts.WebPart wp in mgr.WebParts)
 {
 wp.Hidden = true;
 mgr.SaveChanges(wp);
 }
 web.Dispose();
 site.Dispose();

Test Page has a Content Editor WebPart, Few List View WebParts and a Custom Webparts. Code runs without any errors but does not hide the Content Editor WebPart and Custom Webpart.

I am running this code in a Sharepoint 2010 installation. Any ideas?

**Note:** 

 1. I am not able to hide them using Web Interface as well. 
 2. I am able to change other properties like Title using code and it works perfectly fine for all thr Web Parts.