locked
Set value of Yes/No column in code RRS feed

  • Question

  • Hi All,

    I want to set the value of a Yes/No type column in SP2010 list through code. I tried a lot of options which doesnt seem to be working. Also I see lot of threads suggesting to add value as "Yes", Yes, true, 1, "1" - Can someone suggest which is the correct way -

    Thanks


    -http://lrathi.blogspot.com

    Monday, April 30, 2012 6:50 AM

Answers

  • Hi Laxmikant,

    Try setting the Yes/No type column with the boolean values (true/false) as follows:

    spItem["FieldInternalName"] = true;
    // Use false to set it to "No"
    spItem.Update();

    It should also work with integral values 1 & 0. Make sure that you update the list item after setting this value.

    Hope this helps!




    • Edited by Devang Bhavsar Monday, April 30, 2012 7:56 AM
    • Proposed as answer by Aviw_ Monday, April 30, 2012 8:54 AM
    • Marked as answer by Laxmikant Rathi Wednesday, May 2, 2012 6:24 AM
    Monday, April 30, 2012 7:46 AM