amkahal
Hi Guys,
i have this situation:
database: univ
tables:
students (SID numeric(2) primary key,name varchar(50),majorID numeric(2) foreign key references majors(MID))
majors (MID numeric(2) primary key,name varchar(50))
suppose that i have on my form one textbox for student names, and one combobox for majors.
i want to know how to bind textbox to students.name and combobox to majors.name and make a relationship between them, so when i navigate the databindingsource i should get the name of a sudent + his major in the combobox, and also, i want to make update to the major successfully.
to the problem be clear, the data binding within single table is too easy, but i am talking about data binding within many tables and with relationships.
my real problem is bigger than this, it is about election system, but i assume this small DB to discuss the problem in easy way.
i am waiting for your solutions.
Kassem
I'm not sure I understood what exactly you are trying to achieve, but if I understood this right, it should be very straight forward to do.
What changes first that needs to change the second? The combo-box or the textbox? Whatever comes first, you need to listen to some event (change event, blur (when something loses focus), you need to figure it out according to your requirements) of what changes first, and then inside that event handler call a function of your Data access layer (or Service layer if you have one) which retrieves the relevant data according to the value of the first control, and then bind the result to the second control.