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.
danfa
Member
34 Points
18 Posts
DBNull to Boolean
Mar 08, 2011 11:24 PM|LINK
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
iGulfam
Contributor
4794 Points
947 Posts
Re: DBNull to Boolean
Mar 09, 2011 09:04 AM|LINK
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)
My BLOG
danfa
Member
34 Points
18 Posts
Re: DBNull to Boolean
Mar 10, 2011 01:53 AM|LINK
Works! Thank you!
Dan
iGulfam
Contributor
4794 Points
947 Posts
Re: DBNull to Boolean
Mar 11, 2011 04:44 AM|LINK
My pleasure! :)
Please don't forget to mark the post as answer which helped you
My BLOG