Wednesday, January 19, 2011

Bind SharePoint multiple choice field in custom form

Bind SharePoint multiple choice field in custom form.

You can bind sharepoint multiple choice value in sharepoint check box list control for display Choice field values.
Add SharePoint “InputFormCheckBoxList” and bind as below code.

ASPX Design Code:

Use below code to populate the choice column values in above control.
Server Side CS Code:

// -------------- Populate CheckBox List
SPField multiValueCheckBoxField = objSPList.Fields["multivalued choice field name"];
SPFieldMultiChoice multiValueCheckBoxChoicesField = (SPFieldMultiChoice) multiValueCheckBoxField ;

// for each loop for values add in checkbox list
foreach (string choiceValue in multiValueCheckBoxChoicesField.Choices)
this.multiValueInputFormCheckBoxList.Items.Add(new ListItem(choiceValue, choiceValue));

Happy Coding!!!

No comments:

Post a Comment