Load pID and productname to combobox - c sharp.
-
Brothers, I've successfully coded to load data from db (sql server) to combobox in c sharp (ex: productname); but when I add new data to db (from c sharp), I want to add an pID of productname instead of the productname to db because I have two tables in db which have relationship together (ex: pID, productname) and (ex: cID, pID, qty, price). Lastly, I have another form to add more productname to db; so, how to refresh the combobox (as mentioned above) when this form is closed? Thanks so much :)
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner
-
Brothers, I've successfully coded to load data from db (sql server) to combobox in c sharp (ex: productname); but when I add new data to db (from c sharp), I want to add an pID of productname instead of the productname to db because I have two tables in db which have relationship together (ex: pID, productname) and (ex: cID, pID, qty, price). Lastly, I have another form to add more productname to db; so, how to refresh the combobox (as mentioned above) when this form is closed? Thanks so much :)
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner
Hi Chuon Visoth A Combobox as 2 properties Display Member & Value member. Assign "productname" as your Display member & "pID" as your value member. while saving data to your table assign value member. The "pID" & "productname" both columns should be in the query from which you assign it to commandText & then get Datatable Ex:- combobox1.DisplayMember = "productname" comboBox1.ValueMember = "pID" Thanks & Regards Satish Pai B
-
Hi Chuon Visoth A Combobox as 2 properties Display Member & Value member. Assign "productname" as your Display member & "pID" as your value member. while saving data to your table assign value member. The "pID" & "productname" both columns should be in the query from which you assign it to commandText & then get Datatable Ex:- combobox1.DisplayMember = "productname" comboBox1.ValueMember = "pID" Thanks & Regards Satish Pai B
-
But this wouldn't refresh it, he would also have to update the DataTable that the combobox is bound to.
-
Thanks for your support. I've found the way to load pID and productname; but my second question I've not found it yet. How to do that? HELP ... !
Chuon Visoth Angkor Wat - Cambodia asp.net - c sharp beginner