sharepoint - Programmatically insert a List as a webpart in a webpart page in WSS 3.0 -


I tried to search the net on the web as a web portal to include a list but it Not very fortunate.

How can I add a program to the list as Webpage in a webpage page

Many thanks!

Firstly use these statements.

  Microsoft. SharePoint; Use of Microsoft SharePoint WebPartPages;  

Then in your code,

  // get the first SPS ite site = new SPS ite ("http: // myserver"); SPWeb web = site. OpenWeb (); SPList List = Web List ["MyCustomlist"]; // Create a webpage list ViewWebPart WP = New ListViewWebPart (); Wp.ZoneID = "top"; // Change the ith right area on your page. Wp.ListName = list.ID.ToString ("B"). ToUpper (); Wp.ViewGuid = list.DefaultView.ID.ToString ("B"). ToUpper (); // Web Part Collection SPWebPartCollection coll = web.GetWebPartCollection ("default.aspx", // replace it with the correct page. Storage.Shared); // Add Web Part coll.Add (wp);  

If you want to use custom view, play with:

  SPView view = list.GetUncustomizedViewByBaseViewId (0); Wp.ListViewXml = view.HtmlSchemaXml;  

Hope this helps, W0ut


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -