Groups | Blog | Home
all groups > asp.net webcontrols > april 2008 >

asp.net webcontrols : Convert integervalues to booleans with checkboxfield ( in datagrid )


Tommy DN
4/18/2008 5:31:56 AM
I'm using a datagrid wich uses a dataset.table as datasource.
One field is a integerfield with 1 and 0

Is there a possibility to bind this with a checkboxfield ( using
inheritance for example ? ).
When it's a 0, the checkbox for the cell must be checked and when it's
a 1 it must be unchecked.

Stan
4/24/2008 4:05:13 PM
[quoted text, click to view]

Suppose your integer field is called "with_sugar" where a 1 means with
sugar and a 0 means without sugar.

The checked property of a databound checkbox control could have the
following binding expression:

checked='<%# (int)Eval("with_sugar") == 1 %>' (host page language C#)
or

checked='<%# Eval("with_sugar") = 1 %>' (host page language VB)
AddThis Social Bookmark Button