M
Mike
I am attempting to bind several text and comboboxes on a form to
datatable. The binding appears to work for all the textboxes but not
for the comboboxes. Can somebody tell me what I am doing wrong? I bind
the fields in the Form Load event. Once the user has entered thier
data they push an Enter button which will run da(dt).Update. Again,
the binded textboxes are succesfully written to the database but he
comboboxes are blank??? Here is a simple version of the code I am
using.
'****************************************
cn = New AdoceConnection
cn.Open(db)
dt = New DataTable("tblTagging_Sample")
sql = "SELECT * FROM tblTagging_Sample"
da = New AdoceDataAdapter(sql, cn)
da.Fill(dt)
'Add a new record
Me.BindingContext(dt).AddNew()
'Move to last record
Me.BindingContext(dt).Position = Me.BindingContext(dt).Count - 1
' BIND THE FIELDS
txtPersonel.DataBindings.Add(New Binding("Text", dt, "Personel"))
cboRecorder.DataBindings.Add(New Binding("SelectedValue", dt,
"Recorder"))
txtLocation.DataBindings.Add(New Binding("Text", dt, "Location"))
'**************************************************
Note: I have seen some information suggesting that you need to specify
a Datasource, DisplayMember, ValueMember when binding Comboboxes and
Listboxes but in this case I am not binding to a datasource. Just
manually populating the combobox with the Items Collection property of
my comboboxes.
Thanks!
datatable. The binding appears to work for all the textboxes but not
for the comboboxes. Can somebody tell me what I am doing wrong? I bind
the fields in the Form Load event. Once the user has entered thier
data they push an Enter button which will run da(dt).Update. Again,
the binded textboxes are succesfully written to the database but he
comboboxes are blank??? Here is a simple version of the code I am
using.
'****************************************
cn = New AdoceConnection
cn.Open(db)
dt = New DataTable("tblTagging_Sample")
sql = "SELECT * FROM tblTagging_Sample"
da = New AdoceDataAdapter(sql, cn)
da.Fill(dt)
'Add a new record
Me.BindingContext(dt).AddNew()
'Move to last record
Me.BindingContext(dt).Position = Me.BindingContext(dt).Count - 1
' BIND THE FIELDS
txtPersonel.DataBindings.Add(New Binding("Text", dt, "Personel"))
cboRecorder.DataBindings.Add(New Binding("SelectedValue", dt,
"Recorder"))
txtLocation.DataBindings.Add(New Binding("Text", dt, "Location"))
'**************************************************
Note: I have seen some information suggesting that you need to specify
a Datasource, DisplayMember, ValueMember when binding Comboboxes and
Listboxes but in this case I am not binding to a datasource. Just
manually populating the combobox with the Items Collection property of
my comboboxes.
Thanks!