Click here to Skip to main content
15,900,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have been searching alot with no answer
i have acombobox that have a datasource and let it be table A (table A is a table in a datacontext dx)
i want to save selected value of this combo in field B in table C
that is done by binding selected value of this combo to field B in CbindingSource
and it is saved to the database through datacontext.submitChanges()
but the problem that when i open the form again the selectedvalue cant be retrieved and the dx.combobox selects the first element
how i can handle this issue? should i program it manually?

let me explain i hope that will clarify more
Table A has two attributes ID And Value
combobox.DataSource=dx.A;
combobox.DisplayMember=Value;
combobox.ValueMember=ID
combobox.SelectedValue is bound in design to cbindingSource.B;
Knowing That B Field is the same type as ValueMember
when i submit changes ID value will be stored in database in Field B through the binding
but i dont know how to make the reverse operation which is :
when running the program how to let the selected item in combobox be the
one that has ID Value that is stored in field B (maybe that is through
combobox.SelectedValueChange event )
Posted
Updated 18-Nov-14 3:48am
v2
Comments
Shambhoo kumar 18-Nov-14 7:54am    
please elaborate your question, it's not clear.
ZurdoDev 18-Nov-14 7:56am    
Please click on Improve question and post just the relevant code.
BillWoodruff 18-Nov-14 8:37am    
When you load the Form again are you executing code to update the selection based on the value of field B in table C ?
johannesnestler 18-Nov-14 9:56am    
Which UI tech - I'd assume WPF?
oula alsheikh 18-Nov-14 10:06am    
windows form application and the datacontext is linq to sql

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