I have added a CQWP from visual studio successfully, now I want to fetch the name of all documents from the library named "Sample Docs".
My code is as below :
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.ListUrl = web.Url + "/Sample Docs";
wp.ListName = "Sample Docs";
wp.XslLink = web.Url + "/Style Library/XSL Style Sheets/ItemStyle.xsl";
wp.QueryOverride = "<where> <Eq> <FileRef Name=\"FileLeafRef\" /> <Value Type='Text'/>Sample Docs</Eq></Where>";
webParts.AddWebPart(wp, "Right", 0);
webParts.SaveChanges(wp);
web.Update();
Console.WriteLine("Web part added successfully");
Console.ReadKey();Web part gets inserted successfully but with error, that there is a problem with query...
What should I do? Please help.