Databinding issue...PLease help.thanks

kekinlim

Member
Joined
Jan 12, 2005
Messages
10
Programming Experience
Beginner
Hi everyone,

I encountered a problem which i cannot solve it after one whole day. Feel very disappointed.

I have this form with a lot of textfields and comboboxes. One of the combobox was binded to a table in the dataset call terms(using datasource property and display members) which retrieve all the data from it and display as the comboboxes' options. By the way, my dataset consists of 2 tables which are terms and customer. The rest of the textfield are binded to the customer table in the dataset. Thus after i call
BindingContext(DsCust, "Customer").EndCurrentEdit()

,all the datas from the textfields are updated to the dataset. So do any one know how i can take the value in the combo box which was binded to table terms in the dataset, to be updated to the customer table in the dataset instead?As the datasource of the combobox is the term table, i dont know how to update the value in the combobox to the table customer. Hope someone can help me...Think my vb programming skill is still quite weak... Hope my explanation is not too confusing too..


Thank You
Kekin
 
I try to use the databinding (text) of the combobox. But it still doesnt work. When i used datasource property of the combobox, i think the table term is binded to the combobox. Thus, even if i use the text binding property to bind it to the customer table, the dataset will still not be updated.
 
try tis it worked when i tested it..

Private Sub FillCombo()

Dim CboSet As DataSet

Dim CboTable As DataTable



CboTable = MyObjUser.MyUsers

cbo1.DataSource = CboTable

cbo1.DisplayMember = "userfname"

End Sub

 
sorry bout the other post i wasnt thinkin straigth yesterday.. i just figured out what the real problem is... i'll check if i can help you with our dilema...
 
can explain further what your strying to accomplish...

all i can grasp is that your trying to update the database after adding/ editing the dataset...

and that ou want to get the value within the combobox into the table?
is that right?
 
my datasource of the combo box is from the table call terms. Thus all the items displayed in the combo box are from the term table in the dataset. Other textfields in the form binded to the customer table in the same dataset. Thus when i do a endcurrentedit(), all the data are stored into the customer table in the dataset except the term field which is binded to the term table. Thus is there any way that i can stated that the term combo box update its value into the customer table?thanks
 
1. you can check by tracing if ou are really equating a value to the field.
2. remember that you are executing a single sql statement... if you database restricts null values then an error will occur after ending the transaction and viewing the field, upon access...
3. after saving the dataset... just prompt a messagebox displaying the value of the dataset.table("customer").rows(last).item("field")

hope this helps..
 
What if you had a "post" button and set the text value of the combobox to the correct Customer field right before calling the update dataset method.

I set the delivery date of the delivery table from a date time picker like this...
should be same for combo box.

Dim dt As DateTime = DateTimePicker1.Text
Dim tblDeliveries As DataTable
tblDeliveries = DsDeliveries1.Tables("Delivery")
Dim drCurrentdel As DataRow
drCurrentdel("due date") = dt.ToShortDateString

Hope this helps
 
THanks guys for the help. I manage to solve my problem but another problem arise. I displayed my combobox without any databinding by using the following codes in the form_load.

Dim dr As DataRow

For Each dr In DsCust.Terms.Rows()

cboTerm.Items.Add(dr("initial").ToString)

Next
cboTerm.SelectedIndex = -1

Thus all the items can be listed out from the term datatable. Then i set the combobox databinding property(text) to my customer datatable. The rest of the controls are binded using this way. However, whenever i modify the datas, everything will be updated except terms.

I did a check on the value by using the following...

MsgBox(cboTerm.Text) -- show the changed value

MsgBox(cboGST.Text) -- show the changed value


BindingContext(DsCust, "Customer").EndCurrentEdit()

MsgBox(cboTerm.Text) -- DID NOT show the changed value,show the previous value

MsgBox(cboGST.Text) -- show the changed value

daCust.Update(DsCust)


Hope someone can help me with this. Been trying for few days but cannot solve this. Thanks.
 
Back
Top