Programmatically adding data to SharePoint List’s Choice column

SharePoint has a column type called “CHOICE”. This column will be useful for presenting one of the field from the following

  • Dropdown List
  • Radio Buttons
  • Check Boxes (To Select Multiple Items)

Consider I’ve a list “Resource List” with following columns

Column Name —— Type
Resource Name –> Single Line of Text
Languages Known –> Choice (C#, VB.NET, Java, C, C++) – Multiselect

Languages Known” is the CHOICE field (Check Boxes), to select multiple languages known by the resource.When adding new items to the Resouce List, notice that multiple items selected for the ‘Languages Known’ CHOICE column will be seperated by semi colan(‘;’).

 

 

 
I had a requirement to add the list item by code. I have used “ChoiceA;ChoiceB;..ChoiceN” for storing the ListItem’s multi-select CHOICE field. After adding ListItem by code, I have Edited the newly added item in the browser, but no check box has been selected for the item which was added by code.

Then after a little effort I found that the multi-select CHOICE data is stored as “;#ChoiceA;#ChoiceB;#…;#
See the below code for adding listitem to Resource List.

 

 

Below screen shows the newly added Item in the edit mode

 

Advertisements

2 Responses to Programmatically adding data to SharePoint List’s Choice column

  1. Ukec says:

    Hello,

    I have followed this post and I did exactly what is written here, and it did write an items into a new list item, but i would like to know how to enable a choice filter to filter these elements that I have written in.
    Have you done this or do you know how to do it?

    Thank you for help

  2. Dan says:

    Thank you very much for this post. It really helped me out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: