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… :)

Comments (2)

  1. Here is the sample code, SPWeb web = new SPSite(" http://karthick64:4040/").OpenWeb (); SPField

  2. N says:

    I need to set selecteditemchange event for SPFieldChoice. Can it be done? is there a workaround?