Alec Tang

Professional Web Developer/ Web Designer

I build websites based on the latest web standards providing the best possible solution to your company

  • Home
  • About
  • Portfolio
  • Contact
  • Blog
Subscribe Feed

How to retrieve and update from a multi choice Checkboxlist field

Posted by Alec on Mon, 15 Mar 2010, in ASP.NET C#   Sharepoint   

To create a checkboxlist from a multi choice field:

//create a check box list

SPFieldMultiChoice choices = (SPFieldMultiChoice)oList.Fields[strFieldName];
foreach (string str in choices.Choices){
      cblCheckboxList.Items.Add(new ListItem(str, str));
}

//mark those selected

if (enquiry[“Reasons”] != null){
     SPFieldMultiChoiceValue itemValue = new SPFieldMultiChoiceValue(enquiry[“Reasons”]);
     for (int i=0; i<= itemValue.Count; i++)
          cblCheckboxList.Items.FindByText(itemValue[i]).Selected = true;
}

//To update

SPFieldMultiChoiceValue choices = new SPFieldMultiChoiceValue();
foreach (ListItem ls in cblCheckboxList.Items){
      if (ls.Selected) choices.Add(ls.Value);
}
Enquiry[“Reasons”] = choices;
Comments Be the first to write a comment. Comment gets approved before publishing.

Post Your Comment

 
 
   

Search

 

Latest Posts

  • Sys.WebForms.PageRequestManagerParserErrorException
  • How Google treats Content Duplication
  • How to create HTML column in Sharepoint List View
  • How Sharepoint stores User Data
  • How to send email via Sharepoint
  • Malaysia Airlines launched iPhone Application: MHMobile
  • Intranet, the next big market
  • How to retrieve and update from a multi choice Checkboxlist ...
  • Auto Complete returns giant list of undefined
  • Integrate Ajax Control Toolkit into Sharepoint

Categories

  • Browsers (1)
  • Projects (1)
  • Web Design (6)
  • Sharepoint (20)
  • Telerik (5)
  • Wordpress (1)
  • Internet (1)
  • SQL (5)
  • LINQ (3)
  • ASP.NET C# (33)
  • JavaScripts (3)
  • IIS (0)
  • Industry (1)
  • Tools (8)
  • SEO (4)

Archives

  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (5)
  • February 2010 (4)
  • January 2010 (11)
  • November 2009 (3)
  • October 2009 (1)
  • September 2009 (9)
  • August 2009 (3)
  • July 2009 (4)
  • June 2009 (1)
  • May 2009 (2)
  • April 2009 (8)
  • March 2009 (6)
  • February 2009 (2)
© Copyright 2009 Alec Tang. All Rights Reserved.
This site is conform to W3C Standard XHTML & CSS