Updating a databound combobox
Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
![]() |
•
•
Posts: 45
Reputation:
Solved Threads: 3
Hi, guys!
Got a problem here.
I have a form that when it loads spawns a thread which in turn fills a publicly declared dataset with a table by a dataadapter and then binds a field from the table to a combobox.
This works like a charm.
I can fetch existing records and manipulate the data (edit and update) perfectly.
But this is the crux.
When I clear the form, add information and save it as a new record, everything is stored in the database as it should and I explicitly use the method dataset1.Tables("<tablename>").AcceptChanges after the update to the server.
However, the bound combobox is not updated with the new information.
I have the impression that if you add a record to a table that is bound to a control and force the update on the table, that information is immediatly available to the control.
I've been googling for an answer for three days without much luck.
My last attempt at this involved iterating through the table with
Can you help me find a solution to this?
I connect to a MSSQL 2000 server and use untyped datasets, all by code.
Got a problem here.
I have a form that when it loads spawns a thread which in turn fills a publicly declared dataset with a table by a dataadapter and then binds a field from the table to a combobox.
vb Syntax (Toggle Plain Text)
combobox1.DisplayMember = "fieldName" combobox1.ValueMember = "fieldName" combobox1.DataSource = dataset1.Tables("<tablename>")
This works like a charm.
I can fetch existing records and manipulate the data (edit and update) perfectly.
But this is the crux.
When I clear the form, add information and save it as a new record, everything is stored in the database as it should and I explicitly use the method dataset1.Tables("<tablename>").AcceptChanges after the update to the server.
However, the bound combobox is not updated with the new information.
I have the impression that if you add a record to a table that is bound to a control and force the update on the table, that information is immediatly available to the control.
I've been googling for an answer for three days without much luck.
My last attempt at this involved iterating through the table with
for each row as dataset1.table("<tablename>").Rows. But that took too long and screwed up the thread.Can you help me find a solution to this?
I connect to a MSSQL 2000 server and use untyped datasets, all by code.
Last edited by Oxiegen : Nov 9th, 2006 at 3:56 am.
•
•
Posts: 45
Reputation:
Solved Threads: 3
I solved it myself using the dataview class.
Now everytime I add (or delete) items from the datatable it shows in the combox right away (and selects the latest added item).
vb Syntax (Toggle Plain Text)
Dim dbView As DataView dbView = new DataView(DataSet1.Tables("<tablename>")) dbView.Sort = "id DESC" cmbRegID.DisplayMember = "column2" cmbRegID.DataSource = dbView cmbRegID.SelectedIndex = 0
Now everytime I add (or delete) items from the datatable it shows in the combox right away (and selects the latest added item).
![]() |
Similar Threads
Other Threads in the VB.NET Forum
- IE slow after updating Norton Virus Defs (Web Browsers)
- need help with ComboBox (C++, Dialog) (C++)
- Hiding dataitems in a combobox (VB.NET)
- How to use combobox function (C++)
- updating 2 HTML tables on one PHP page (PHP)
- Filling a ComboBox.... (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Timer Control Help
- Next Thread: my vb video turtorial for beginers(coming soon)
•
•
•
•
Views: 3825 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode