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

  • SEARCH
  • Home
  • 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 am busy building an application in which I am reading data from more
I'm relatively new to Rails and busy building an app with various access levels,
I have a couple of concerns, I'm busy building a normal .mobi site for
I'm busy writing a application that refreshes a IFrame completely using javascript, now my
I have been busy in my project creating a webapp (in struts) that manages
Let's assume that we are building a high traffic site that will be used
I am busy on a project that involves calling the API's of nine other
I'm building a web site for an artist who has had a custom font
I'm busy building an MVC application in PHP using Kohana MVC framework, and it

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.