Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my application i have a combo-box with list of some data from DB. The combo-box data-source is given set to a binding source. The binding source has a data-set as Data-source and a Data-table as data-member.
I update this combo-box after adding or editing or deleting an entry. The updating is done by again calling the code for binding. Now all the items in the combo-box disappears.
I don't know how it happens.

A sample work is in the link http://www.filedropper.com/students_1. the db is included with it.
Posted
Comments
Kuthuparakkal 7-Sep-12 3:56am    
post the code buddy
good.shankar 7-Sep-12 4:05am    
code in the link...
Kuthuparakkal 7-Sep-12 4:26am    
not everybody got time to sign-in to that crap, download your solution, unzip and read it. Would you do this, seriously i do not.
CodeHawkz 7-Sep-12 4:30am    
WOahhh Kuthuparakkal. Shouldn't you be a bit concerned about your language in such a public forum? I suggest you reflect more professionalism in future. Btw, you don't have to sign into that site, just click the link and fill in the captcha code and the file is downloaded.

Regards
Kuthuparakkal 7-Sep-12 4:39am    
No worries, please do the way you like, no offence. But expectation reduces joy. Thats just happened here!

1 solution

Change the definitions:

C#
DBOprX dbOpr = new DBOprX();
BindingSource bs = new BindingSource(new System.ComponentModel.Container());
DataSet ds = new DataSet();


to:

C#
DBOprX dbOpr;
BindingSource bs;
DataSet ds;



Change the GetData()

C#
void GetData()
{
dbOpr = new DBOprX();
bs = new BindingSource(new System.ComponentModel.Container());
ds = new DataSet();
ds = dbOpr.SelectMSSQLQry("Select * FROM Stu", "Students");
bs.DataMember = "Students";
bs.DataSource = ds;

cboStudents.DataSource = bs;
cboStudents.DisplayMember = "Name";
cboStudents.ValueMember = "Id";

cboStudents.SelectedIndex = -1;
}
 
Share this answer
 
v2
Comments
good.shankar 7-Sep-12 6:20am    
Thanx bud...!!!
Kuthuparakkal 7-Sep-12 6:29am    
no issues, you're most welcome!... keep codin...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900