[UPDATE 01.Feb.2012: wp.ViewGuid = string.Empty gilt nur für 2007]
Hier eine Erklärung für 2010
[ENDUPDATE]
[UPDATE: Set View to "Summary View"]
using Microsoft.SharePoint; using Microsoft.SharePoint.WebPartPages; // Get a reference to a web and a list SPSite site = new SPSite("http://localhost:8000"); SPWeb web = site.OpenWeb(); SPList list = web.Lists["Contacts"]; // Instantiate the web part ListViewWebPart wp = new ListViewWebPart(); wp.ZoneID = "Left"; wp.ListName = list.ID.ToString("B").ToUpper();
// wp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();
// Set the ViewGuid to string.Empty to get the "Summery View"
// including the "Add New Item"-Button
// Thanks to sadomovalewp.ViewGuid = string.Empty;
// Get the web part collection SPWebPartManager mgr = new SPWebPartManager("default.aspx", Storage.Shared);
// Add the web part
coll.Add(wp);
Keine Kommentare:
Kommentar veröffentlichen