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 36597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:25:05+00:00 2026-05-10T14:25:05+00:00

I want to use the MultipleLookupField control in a web page that will run

  • 0

I want to use the MultipleLookupField control in a web page that will run in the context of SharePoint. I was wondering if anyone would help me with an example, which shows step by step how to use the control two display two SPField Collections.

  • 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. 2026-05-10T14:25:06+00:00Added an answer on May 10, 2026 at 2:25 pm

    I’m not entirely sure I understand your question, especially the bit about displaying two SPField collections. Sorry if this turns out to be the answer to a completely different question!

    Anyway here’s a quick demo walkthrough of using the MultipleLookupField in a web part.

    Create a team site. Add a few tasks to the task list. Also put a document in the Shared Documents library. Create a new column in the Shared Documents library; call it ‘Related’, have it be a Lookup into the Title field of the Tasks list, and allow multiple values.

    Now create a web part, do all the usual boilerplate and then add this:

    Label l; MultipleLookupField mlf;  protected override void CreateChildControls() {     base.CreateChildControls();     SPList list = SPContext.Current.Web.Lists['Shared Documents'];     if (list != null && list.Items.Count > 0)     {         LiteralControl lit = new LiteralControl('Associate tasks to ' +                               list.Items[0].Name);         this.Controls.Add(lit);          mlf = new MultipleLookupField();         mlf.ControlMode = SPControlMode.Edit;         mlf.FieldName = 'Related';         mlf.ItemId = list.Items[0].ID;         mlf.ListId = list.ID;         mlf.ID = 'Related';         this.Controls.Add(mlf);          Button b = new Button();         b.Text = 'Change';         b.Click += new EventHandler(bClick);         this.Controls.Add(b);          l = new Label();         this.Controls.Add(l);     }  }  void bClick(object sender, EventArgs e) {     l.Text = '';     foreach (SPFieldLookupValue val in (SPFieldLookupValueCollection)mlf.Value)     {         l.Text += val.LookupValue.ToString() + ' ';     }     SPListItem listitem = mlf.List.Items[0];     listitem['Related'] = mlf.Value;     listitem.Update();     mlf.Value = listitem['Related']; }  protected override void OnInit(EventArgs e) {     base.OnInit(e);     EnsureChildControls(); } 

    Granted, this is borderline ridiculous — everything is hard-coded, there is no error-handling at all, and it serves no useful purpose — but it’s only meant as a quick demo. Now build and deploy this web part and add an instance of it to your team site’s homepage; it should allow you to get and set the tasks which are associated with the first document in the library.

    The strange bit towards the end of the button Click handler, where we read a value from mlf.Value and then write it back again, appears to be required if you want the UI to stay in sync with the actual list values. Try omitting the last line of bClick to see what I mean. This has been driving me nuts for the last hour or so, and I’m hoping another commenter can come up with a better approach…

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

Sidebar

Related Questions

I want to use the Web Browser control within an mono application, but when
I want to use CSS sprites on a web site instead of separate image
Below is my stored procedure. I want use stored procedure select all row of
I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom
I want to use Powershell to write some utilities, leveraging our own .NET components
I want to use the functions exposed under the OpenGL extensions. I'm on Windows,
I want to use the Publish.GacRemove function to remove an assembly from GAC. However,
I want to use CodeDOM to both declare and initialize my static field in
I want to use SQL Profiler to trace the queries executed agains my database,

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.