Get valve from combobox (using linq to Sql)
-
Wednesday, March 21, 2012 3:44 PM
I have 2 tables in the database
carrierandvendor.vendorhas a foreign key ofCarrier_Id. When the user want add a vendor, the user will select a carrier from a combobox where the valve from carrier table.The problem I facing now is that,I don't know how to get the valve from combobox so that I can insert it into the database.
I use this code to get valve from carrier table to show in the combobox.
MyinvoiceDataDataContext contect = new MyinvoiceDataDataContext(); var st = from s in contect.Carriers select new { s.CarrierID, s.CarrierName }; comVendorCarrier.ItemsSource = st; comVendorCarrier.DisplayMemberPath = "CarrierName"; comVendorCarrier.SelectedValuePath = "CarrierID";
All Replies
-
Wednesday, March 21, 2012 6:40 PM
What platform are you using, Desk top, WPF, Web?
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful". -
Friday, March 23, 2012 4:12 PMBoth Desktop and WPF , using linq to sql.
-
Friday, March 23, 2012 5:06 PM
var item = YourCombobox.SelectedItem;
item.GetProperty("PropertyName").GetValue(item , null);Please mark as reply if helped.
Also visit my blog http://msguy.net/
- Edited by Michael Samteladze Friday, March 23, 2012 5:07 PM
- Marked As Answer by Thivakaran siva Saturday, March 24, 2012 3:42 AM
-
Saturday, March 24, 2012 3:43 AM
Hi, i found one more way ... i can also use this..
int SelectedCarrierId = int.parse(comVendorCarrier.SelectedValue.ToString());
-
Saturday, March 24, 2012 6:14 PM
Not completely sure about this one, but I meet your case scenario lots of time and solution I've displayed above s 100% reliablePlease mark as reply if helped.
Also visit my blog http://msguy.net/- Marked As Answer by Thivakaran siva Thursday, March 29, 2012 4:03 PM

