9
Reply

Drill down combo boxes

Sarah Reynolds

Sarah Reynolds

Jan 22 2012 12:41 PM
2.4k
Hi Everyone,

I'm learning c# and i'm about to pull my hair out! I need to have one combo box populated from a database based on values selected in another combo box (also populated from a database).

I have 2 tables, (Courses and Students )

The 'Courses' Table contains  CourseID , CourseTitle 
The 'Students' Table contains StudentID,  CourseID , FirstName, Surname

CourseID are both unique keys.

I need to be able populate a 'Students' combobox with only students on the course selected in the 'Courses' dropdown box. (Both comboboxes are on the same form).

My problem is I just cant do it!! I've spent the best part of 2 days looking for examples/tutorials etc but I have got a bit confused with creating datatables/datasets to fill the comboboxes etc. 

I want to try and do this in code only rather than using visual studio to create datasets etc so I can understand the process a bit more but the longer I spend failing the less it all makes sense!

Can anyone point me to a really easy to follow basic example or perhaps even be kind enough to share any code you may already have so that I can attempt to 'doctor' it for my needs.

I'm sure that once I can see this working in a simple project I will gain a better understanding but at the moment I just seem to be going backwards!!

Many Thanks
Sarah

Answers (9)