SharePoint 2013 How to add Promoted link list view web part in page programmatically C#

Wednesday, June 12, 2013

SPLimitedWebPartManager limitedWebPartManager = null;
                    SPList targetList = targetWeb.Lists["PromotedLink"];

                    XsltListViewWebPart listPomotedView = new XsltListViewWebPart();
                    listPomotedView.ListId = targetList.ID;
                    listPomotedView.ViewGuid = targetList.Views["Tiles"].ID.ToString("B").ToUpper();

                    limitedWebPartManager = targetWeb.GetLimitedWebPartManager(targetWeb.Url + "/" + "default.aspx", PersonalizationScope.Shared);
                    limitedWebPartManager.AddWebPart(listPomotedView, "Top", 3);
                    limitedWebPartManager.SaveChanges(listPomotedView);
                    targetWeb.Update();

share this post
Share to Facebook Share to Twitter Share to Google+ Share to Stumble Upon Share to Evernote Share to Blogger Share to Email Share to Yahoo Messenger More...

0 comments: