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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:24:29+00:00 2026-06-15T01:24:29+00:00

I have to add a choice field (dropdown) to a sharepoint list. I’m using

  • 0

I have to add a choice field (dropdown) to a sharepoint list. I’m using the SharePoint API in Visual Studio.

Here is me code. I have tried to run this and there are no errors but it doesn’t work.

private void addChoiceField(SPFeatureReceiverProperties properties, String _listName, String _fieldName)
        {
            using (SPWeb _web = properties.Feature.Parent as SPWeb)
            {
                    SPList _list = _web.Lists.TryGetList(_listName);
                    writeLog(properties, "list name:" + _listName);
                    SPFieldChoice _fieldDD = (SPFieldChoice)_list.Fields[_fieldName];
                    writeLog(properties, "fieldname:" + _fieldName);
                    if (_fieldName == "State")
                    {
                        _fieldDD.Choices.Clear();
                        _fieldDD.Choices.Add("Gesloten-Verloren");
                        _fieldDD.Choices.Add("Analyse nodig");
                        _fieldDD.Choices.Add("Onderhandeling of revise");
                        _fieldDD.Choices.Add("Presentatie of demo");
                        _fieldDD.Choices.Add("Voorstel voor prijsofferte");
                        _fieldDD.Choices.Add("Prospect");
                        _fieldDD.Choices.Add("Waardevol");
                        _fieldDD.Choices.Add("Gesloten-Gewonnen");
                        _fieldDD.Update();
                    }
}
}

Does anyone knows what’s wrong or how to add a choicefield in a different way using the API?

  • 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-15T01:24:30+00:00Added an answer on June 15, 2026 at 1:24 am

    You need to call

    _list.Fields.CreateNewField

    to actually add it to the list instead of trying to pull an existing field from the list.

    Here is a link to the method description: http://msdn.microsoft.com/en-us/library/microsoft.harepoint.spfieldcollection.createnewfield.aspx

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

Sidebar

Related Questions

I have written the following code choice /m Do you want to add another
I have this field in form builder ->add('pay_method', 'choice', array( 'choices' => array( 'telnet'
I need to add a choice field to sharepoint that has values depending on
I have a handler /choice with a textarea field and /choicehandler that writes the
I have the normal PayPal donation button. I want to add two multiple choice
I have to develop a web part for SharePoint that reads a list and
I'm working with a django form, and I have a choice field. I think
So my goal here is to have a single search field in an application
I have to add a custom layout in a relative layout on a button
I have an add this button on the website that is rendering a border

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.