Databound Listbox not updating?

qaisqais

Member
Joined
Mar 29, 2010
Messages
14
Programming Experience
Beginner
have a listbox display a list of product names which it reads from a database, bound using the inbuilt bind to datasource options, however when the product names are updated in the database or more are added etc no change is reflected in the listbox, only the initial names from when it was first bound appear! how to fix this?
 
If you have bound the ListBox to a DataTource and the contents of that DataTable changes, the ListBox will update to reflect that. Presumably you aren't actually changing the contents of the bound DataTable. That's how you fix it: change the data in the bound DataTable. If you want to save changes to the database then you change the DataTable first and then save those changes, not the other way around.
 
I'm sure the changes are being made directly to the data table, I've checked many times, inserted new records through my program and also directly into the database, both methods insert into the table fine. However the listbox is still only displaying products from when it was first bound. I bound using the inbuilt method where you click the listbox and select datasource etc display member valuemember...when I manually attached the datasource with my own code it did display correctly however the other fields dependant on the listbox selected value got messed up and clicking any other listbox items made all entries disappear, so I just reverted back to the inbuilt binding as to not mess up things further.
 
haha I'm sure I'm doing a lot of things wrong, the listbox is on the AddItems form, apologies for the ugly code and lack of organisation/structure
 

Attachments

  • mySystemRemake.zip
    148 KB · Views: 22
I'm not going to download your attachment, unzip it, open it in VS and then try to find out where the problem might be, all before there's any chance of finding the cause. You post the relevant code and only the relevant code here directly and then we can read it.
 
Back
Top