Hi,
> so basically:
> checkbox.checked =1
[quoted text clipped - 3 lines]
> any ideas how to get this working? ive set the variable as a decimal
> (is that correct?)
Hope this is an answer to your question, try this:
int valueInSql = 1;
checkbox.Checked = (valueInSql == 1 ? true : false)
or even simply
checkbox.Checked = (valueInSql == 1);
Note that this doesn't alarm you if the value in sql was anything
other than 0 or 1.
PS. As in the example, I'd use an int for this instead of decimal, or
at least any other whole-number type, one that is large enough to hold
the type of the column in your DB.
Regards,
Jeroen
nologo - 31 Jan 2008 11:10 GMT
> Hi,
>
[quoted text clipped - 24 lines]
> Regards,
> Jeroen
Thanks you mate, works a treat!
nologo - 31 Jan 2008 14:44 GMT
> Hi,
>
[quoted text clipped - 24 lines]
> Regards,
> Jeroen
Ok so im using:
Button btn_UpdateDatabase on click
Struct.valueinSql = 0;
chk_Box.Checked=(Struct.valueinSql==1);
This successfully updates the database once i click UPDATE..but only
with the statement: Struct.valueinSql = 0;
the following statement has no effect.
(chk_Box.Checked=(Struct.valueinSql==1);)
If i remove: Struct.valueinSql = 0;
I get the following errors:
"Use of possibly unassigned field 'valueinSql"
If i use this code:
int valueinsql = 1;
chk_Box.Checked=(Struct.valueinSql==1);
Error message: "The variable 'valueinsql' is assigned but its value is
never used"
any ideas?
If you are binding the column to some other object which is typed as an
integer, then you might want to attach to the Format and Parse methods on
the Binding to transform the value between the data source and the bound
control. This will let you convert from an integer to a boolean and vice
versa.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> All,
>
[quoted text clipped - 12 lines]
>
> Thanks