I am adding an XsltListViewWebPart from code behind, my code is:
static void Main(string[] args)
{
SPSite site = new SPSite("http://bipc11:1234/sites/publishing1");
SPWeb web = site.RootWeb;
web.AllowUnsafeUpdates = true;
SPLimitedWebPartManager webParts = web.GetLimitedWebPartManager(web.Url + "/SiteAssets/webparts.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
SPList list = web.Lists["Images"];
XsltListViewWebPart webPart = new XsltListViewWebPart();
webPart.ListId = list.ID;
webPart.XslLink = web.Url + "/Style Library/Custom View/ViewCart.xsl";
webParts.AddWebPart(webPart, "Right", 0);
webParts.SaveChanges(webPart);
web.Update();
Console.WriteLine("Web Part Added Successfully");
Console.ReadKey();
}
Images is the library in which pictures are stored and the path web.Url +"/Style Library/Custom View/ViewCart.xsl
specifies the copy of file AssetPicker.xsl
which renders data in thumbnail view.
My problem is that webpart displays this output instead of displaying this.
What am I missing?