我正在使用下面的代碼將SummaryLinkWebPart添加到頁面,並且還添加了幾條指向該wehbpart的鏈接。我現在可以在頁面上看到webpart,但它裏面沒有任何鏈接。有人知道代碼有什麼問題嗎?以編程方式添加SummaryLinkWebPart不顯示鏈接
var wpm = web.GetLimitedWebPartManager("Pages/default.aspx", PersonalizationScope.Shared);
SummaryLinkWebPart slwp = new SummaryLinkWebPart();
for (int counter = 0; counter < list.ItemCount; counter++)
{
urlField = list.Items[counter]["URL"].ToString().Split(',');
SummaryLink link = new SummaryLink(urlField[1].Trim());
slwp.SummaryLinkValue.SummaryLinks.Add(link);
slwp.SummaryLinkValue.SummaryLinks[counter].OpenInNewWindow = true;
slwp.SummaryLinkValue.SummaryLinks[counter].LinkUrl = urlField[0].Trim();
slwp.SummaryLinkValue.SummaryLinks[counter].Description = urlField[1];
slwp.Style = "Image on left";
Console.WriteLine(link.LinkUrl + link.Title);
}
wpm.AddWebPart(slwp, lvwp.ZoneID, slwp.ZoneIndex + 1);
我不喜歡它,但它的工作原理!謝謝! – 2014-04-28 18:47:05