SharePoint 2003: Setting MultiChoice Fields Programmatically

When using a choice field in SharePoint 2003, you may want to allow multiple values to be selected via checkboxes. When doing so, the field becomes type MultiChoice behind the scenes (different to a Choice type). To set assign multiple choice values to a multichoice field programmatically you need to separate different choice instances with a semicolon then hash (as well as at the start and end of the string). Note I worked this out by looking in the UserData table for my site collection.

currentList = new SPSite("mysiteurl").OpenWeb().Lists["MyList"];
SPListItem listItem = currentList.Items.Add();
listItem["nameOfAMultiChoiceField"] = ";#red;#green;#blue;# ";
listItem.update();

You May Also Like

About the Author: rnowik

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.