I have added a content query web part from visual studio and I am displaying the data from a document library of root site.
I want to set the ItemStyle property to Title and Description and assigne them respective value i.e. Title=Document Title and Description=Editor.
My code for adding web part is:
SPSite site = new SPSite("http://bipc11:1234/sites/publishing1");
SPWeb web = site.RootWeb;
web.AllowUnsafeUpdates = true;
SPLimitedWebPartManager webParts = web.GetLimitedWebPartManager("SiteAssets/webparts.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
ContentByQueryWebPart wp = new ContentByQueryWebPart();
wp.Title = "My web part using OM";
wp.ListGuid = "eff50fad-f899-4e26-a9a4-1b40aedfc9be";
wp.WebUrl = "~SiteCollection";
wp.ItemStyle = "Title and Description";
webParts.AddWebPart(wp, "Right", 0);
webParts.SaveChanges(wp);
web.Update();
Console.WriteLine("Web part added successfully");
Console.ReadKey();
How do I change the property? Please help.