locked
DBNull to Boolean RRS feed

  • Question

  • User292474935 posted

    Hi,

    I'm designing a form that retrieves boolean values that allow null. I'd like to convert these values to 'false' before binding to checkbox controls (using objectdatasource). I'm thinking to do this using the ObjectDataSource.Selected method but I'm not sure how, and maybe there is a better way? The data from the  ObjectDataSource is bound to a Formview. 

    Thank you,

    Dan

     

     

    Tuesday, March 8, 2011 7:24 PM

Answers

  • User-1971614856 posted

    You can do this using your SQL Query. Your SQL Query will look like (Let us suppose Boolean Database field name is IsActive)

    SELECT ISNULL(IsActive, 0) AS IsActive FROM [TABLE_NAME]

     

    Now if IsActive field will be null then you will get the 0 (false)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 9, 2011 5:04 AM

All replies

  • User-1971614856 posted

    You can do this using your SQL Query. Your SQL Query will look like (Let us suppose Boolean Database field name is IsActive)

    SELECT ISNULL(IsActive, 0) AS IsActive FROM [TABLE_NAME]

     

    Now if IsActive field will be null then you will get the 0 (false)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 9, 2011 5:04 AM
  • User292474935 posted

    Works! Thank you!

     

    Dan

     

     

    Wednesday, March 9, 2011 9:53 PM
  • User-1971614856 posted

    My pleasure! :)

    Please don't forget to mark the post as answer which helped you

    Friday, March 11, 2011 12:44 AM