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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:26:44+00:00 2026-06-10T23:26:44+00:00

I’ve figured out how to add a record into a library. The only thing

  • 0

I’ve figured out how to add a record into a library. The only thing I am trying to figure out is how (or maybe where) do I save a user’s selection from a lookup list?

In the below code snippet, I am saving a new list item. It saves without error, but the fields “AwardType” and “AwardReason” are lookup fields and, although I do not get an error, nothing gets saved to them. How do I save to a lookup field selection from a user?

using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
    using (SPWeb web = site.OpenWeb())
    {
        using (FileStream fs = (new FileInfo(fileUpload.PostedFile.FileName)).OpenRead())
        {
            SPList list = web.Lists["Awards"];
            Hashtable ht = new Hashtable();
            ht.Add("wfRecipientName", txtRecipientName.Text);
            ht.Add("Office", txtOrganization.Value);
            ht.Add("AwardType", ddAwardTypes.SelectedValue);
            ht.Add("AwardReason", ddAwardReasons.SelectedValue);

            SPFile destfile = list.RootFolder.Files.Add(fileUpload.FileName, fs, ht, false);
        }
    }
}
  • 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-06-10T23:26:45+00:00Added an answer on June 10, 2026 at 11:26 pm

    Storing a lookup’s value is done with SPFieldLookupValue(ID, Value).

    You need to store the object returned by this method in a list item field, not a property via a hash table. In my example below, Awards list is document library and AwardType is a field of type lookup.

    SPList list = web.Lists["Awards"];
    Hashtable ht = new Hashtable();
    ht.Add("Office", "Chicago"); // standard property
    SPFile file = list.RootFolder.Files.Add(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName), fs, ht, true);
    SPListItem item = file.Item; // get the item for the just-added file.
    
    // assign the lookup column using SPFieldLookupValue
    item["AwardType"] = new SPFieldLookupValue(
        Int32.Parse(DropDownList1.SelectedValue),
                DropDownList1.Text);
    item.Update();  // to save the lookup column.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

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.