MOSS 2007 : WSS 3.0 : How do you add items into Choice Site Column type.

Here is the sample code,                 SPWeb web = new SPSite(“http://karthick64:4040/”).OpenWeb();                SPField spField = web.Fields[“MyChoice”];                SPFieldChoice choiceFields = (SPFieldChoice)spField;                string[] choices = new string[3] {“x”, “y”, “z”};                foreach (string choice in choices)                {                    choiceFields.Choices.Add(choice);                }                choiceFields.Update(); Keep Exploring… 🙂

2

MOSS 2007 : WSS 3.0 : How do you add a new Site Column to a Content Type using the MOSS object model?

How do you add a new Site Column to a Content Type using the MOSS object model?  Here is the sample code    SPWeb web = new SPSite(“http://localhost:4040”).OpenWeb();    SPContentType myCT = web.ContentTypes[“myNewContentType”];    myCT.FieldLinks.Add(new SPFieldLink(web.Fields[“abc”]));    myCT.Update();   Note : The following MSDN article speaks about “Updating Child Content types”. http://msdn2.microsoft.com/en-us/library/ms442695.aspx The example given…

3

MOSS 2007: WSS 3.0: How to add/delete/update site columns by using SharePoint WebService

SharePoint’s Webs webservice can be used to add/delete/update site columns. Unfortunatley MSDN/SDK doesnot has the sample yet. Here I provide the sample code.             //webs webservice object             localhost.Webs websService = new ContentTypeAndSiteColumn.localhost.Webs();             //url for the webservice             websService.Url = “http://localhost:4040/_vti_bin/Webs.asmx”;             //credential             websService.Credentials = System.Net.CredentialCache.DefaultCredentials;               //xmldocument object             XmlDocument xDoc…

7