Opening Web Parts Gallery Programmatically
Navigating to the Web Part Gallery in the browser interface takes you to http://site collection URL/_layouts/_catalogs/wp/Forms/AllItems.aspx. Attempting to open the list through “_catalogs/wp” will fail:
SPList spWPG = spWeb.Lists["_catalogs/wp"]; // does not work
Instead, you need to use the following code:
SPList spWPG = spWeb.Lists["Web Part Gallery"];
Reference: http://meiyinglim.blogspot.com/2007/10/programatically-organizing-web-parts-in.html
Advertisement