0
votes

I receive my parameters as 1's or 0's to fill a datagrid full of checkboxes. The funny bit here is that the checkbox control recognizes them as booleans! But then my checkbox control has a change property in which these numbers are converted to "true" or "false".

How can I convert this changes to ones and zeroes again to send them back to database?

I believed the ByteArray function "writeAsBoolean" would work, but I forgot the rest of the values inside the datagrid are kept as numbers. So that function will not recognize them and my webservice will ignore them, failing to write the data.

To write them to database I need to loop throughout the datagrid.

2

2 Answers

1
votes

If you're looping through the datagrid anyway, use a ternary expression (where var toDatabase:Number):

toDatabase = (checkBoxVariable.isChecked) ? 1 : 0;

2
votes

You can cast them however you like:

Boolean(1) //true
Boolean(0) //false
Number(true) //1
Number(false) //0

Or what I think you need:

String(Number(true)); //"1"
String(Number(false)); //"0"