Check Box binding

  • Thread starter Thread starter Flying Whiz
  • Start date Start date
F

Flying Whiz

I have to a bind check box in my application with a value which is
coming from database.

I have two values which are coming from database.

X - Check

Y - UnCheck

I am trying to do databinding with check box as below.

chkPropAcct.DataBindings.Add("Checked", dt, "PROP_Value")

Can any plz give help me out to do Data binding with check box

Thanks
Whiz
 
After you populated your data table add a calculated column to it:

C#
dt.Columns.Add("PropBool", typeof(bool), "PROP_Value = 'Y'");
VB
dt.Columns.Add("PropBool", GetType(Boolean), "PROP_Value = 'Y'")

Then bind your check box property to this new column
 
Hi,

Thanks for the reply to my posting.I am doing in the following to bind
the check box, but some how it's not binding.Can you plz help where am I
going wrong.


Dim dt As System.Data.DataTable = New
System.Data.DataTable("Prop_Table")

dataAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter(cmd)
dataAdapter.Fill(dt)
dt.Columns.Add("PropBool", GetType (Boolean), "Prop_Value = 'Y'")
dt.Columns.Add("PropBool", GetType(Boolean), "Prop_Value = 'X'")

ChkPropVal.DataBindings.Add("Checked", dt, "Prop_Value")

Thanks
Flyingwhiz
 
It should be

Dim dt As System.Data.DataTable = New
System.Data.DataTable("Prop_Table")

dataAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter(cmd)
dataAdapter.Fill(dt)
dt.Columns.Add("PropBool", GetType (Boolean), "Prop_Value = 'Y'")

ChkPropVal.DataBindings.Add("Checked", dt, "PropBool")
 
Thanks Alex.Now I am able to bind the check box, but when I did 'move
next' to go to next record it's giving an error saying "Column
'PropBool' is read only". How can I fix this ??

Thanks
Flyingwhiz
 
Alex !!! Now I am able to bind the check box, but when I did 'move next'
to go to next record it's giving an error saying "Column 'PropBool' is
read only". How can I fix this ??
You help is appreciated.

Flyingwhiz
 
Alex !!! Now I am able to bind the check box, but when I did 'move next'
to go to next record it's giving an error saying "Column 'PropBool' is
read only". How can I fix this ??
Your help is appreciated.

Flyingwhiz
 
Back
Top