Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1086313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:47:51+00:00 2026-05-16T22:47:51+00:00

I am busy building a custom webpart with various textboxes and lookup fields. All

  • 0

I am busy building a custom webpart with various textboxes and lookup fields. All of them are saving correctly apart from the lookup fields that allows for multiple selections. I dont have this problem with lookup fields that only allow for one value to be selected.

Below is the code for getting all the selected items in my checkboxlist, converting it to a multichoice value and assigning to my list[columnname]

try
{
    SPFieldMultiChoiceValue _segmentchoices = new SPFieldMultiChoiceValue();
    foreach (ListItem ls3 in _segment.Items)
    {
        if (ls3.Selected) _segmentchoices.Add(ls3.Value);
    }
    myItems["Segment"] = _segmentchoices;
    myItems.Update();
}
catch (Exception ex) { _errorMessage += "||| Segment : " + ex.Message; }

The values list (_segmentchoices) is correctly created and looks like this : {;#1;#2;#3;#4;#5;#}

However when its saved it only saves values 1, 3, and 5.

My code is not generating an error, so I am at a loss at what could be wrong. Any ideas on what I need to look at? Am I going about it the wrong way?

Any assistance would be appreciated.
Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:47:52+00:00Added an answer on May 16, 2026 at 10:47 pm

    I just realized you are talking about a multi-select lookup field. The format should be something like: 2;#Procedures;#3;#Systems;#7;#Services

    The behavior you describe makes sense because it is probably interpreting ;#1;#2;#3;#4;#5;# like this: get the item in the lookup list with a lookupID of 1 (lookupValue is 2), lookupID of 3 (lookupValue is 4), and lookupID of 5 (lookupValue is empty)

    Here is some code that you can use to update a multi-select choice field:

    using (SPSite site = new SPSite(siteUrl))
    {
        using (SPWeb web = site.OpenWeb())
        {
            SPList list = web.Lists[listName];
            SPListItem item = list.Items[0];
    
            SPFieldLookupValueCollection spflvc = new SPFieldLookupValueCollection();
            spflvc.Add(new SPFieldLookupValue(3, string.Empty));
            spflvc.Add(new SPFieldLookupValue(7, string.Empty));
            item["Keywords"] = spflvc;
            item.Update();
        }
    }
    

    The second parameter to SPFieldLookupValue doesn’t seem to care if it is passed string.Empty which also might explain why it ignores them above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm busy building my first MVC app that uses the Telerik MVC components. Their
I'm currently busy making a Python ORM which gets all of its information from
I am busy building a small theme options page for one of clients and
I am curently busy with bulding a synthax document in SPSS and have a
I am busy trying to configure a build server for TFS2010. My project has
Is this loop busy waiting, I would think the wait call takes care of
In a busy repository, I can foresee some files with too much central logic
I'm busy learning Prism 4 and the in and outs of everything, but I've
I'm busy getting confused about non-deterministic destruction. In an answer to another question I
Recently I've been busy with some PHP framework - completely off-topic by the way.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.