Condividi tramite


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

Here is the sample code,

                SPWeb web = new SPSite("https://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... :)

Comments

  • Anonymous
    May 22, 2007
    Here is the sample code, SPWeb web = new SPSite(" http://karthick64:4040/").OpenWeb (); SPField

  • Anonymous
    August 09, 2011
    I need to set selecteditemchange event for SPFieldChoice. Can it be done? is there a workaround?