locked
What is the If Else Statement to store Checkbox Value? RRS feed

  • Question

  • User-691689463 posted

    What is the If Else Statement to store Checkbox Value?

    Under the btn_create_click event,

    how can i put in if else statement so that if Checkbox is checked, stored the checkbox value. Else database will reflect NULL?

    Thanks.

    Saturday, January 28, 2012 5:52 AM

All replies

  • User-1360095595 posted
    If Checkbox1.Checked set the parameter value to the value of the checkbox; otherwise set it to DBNull.Value.
    Saturday, January 28, 2012 6:04 AM
  • User-691689463 posted

    It is not working. When i key in DBNull.Value,

    it became red underline.

    Saturday, January 28, 2012 6:33 AM
  • User-1360095595 posted
    Maybe this reference page will help: http://msdn.microsoft.com/en-us/library/system.dbnull.value.aspx
    Saturday, January 28, 2012 6:37 AM
  • User1418460105 posted

    if(checkbox1.checked)

    {

    a=checkbox1.text;

    }

    else

    {

    }

    Saturday, January 28, 2012 7:13 AM
  • User-691689463 posted

    i dont know why but cant.

    i uses session, does it matter?

    Saturday, January 28, 2012 7:20 AM
  • User705563967 posted

    can you past the code its better to  understand what is the problem. It is very simple logic

    if(checkbox1.checked)

    bool flag= checkbox1.checked

    else

    {

    // what ever you want

    }

    Monday, February 6, 2012 12:34 AM