c# - how to get particular column value from DataGrid and add it as combobox items in wpf using Linq to sql concept -


state

i have loaded above table state in datagrid control.but want particular column state_name , add it's value(tx,tn,up,nul,.....) combobox items. belove code wrote load state table datagrid control.

 using (dataclasses1datacontext _mc = new dataclasses1datacontext())         {             var _mycountry = cntry in _mc.gettable<state>() select cntry;             grd_table.itemssource = _mycountry;                         } 

there many solutions use linq because of how easy use. guess want value of comboboxitems state_id of state , displayed name state_name? following code you?

        grd_table.itemssource = _mycountry;         combobox.itemssource = (from m in _mycountry select m).tolist();         combobox.displaymemberpath = "state_name";         combobox.selectedvaluepath = "state_id"; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -