tblProd p = new tblProd();
p.categoryname=cb_category.SelectedValue.ToString();
I get the string as " Demo.tbl_category " I get the name of the table as string instead of a category name. I have two properties in my category model category name and description. I have bound the combobox
source to observablecollection
of category and I have categoryname as the displaymemberpath
in combobox
.
plz help me.thanks in advance.
I m using linq .
You are getting an instance of the object and its ToString
.
SelectedValue
contains an instance of the object tbl_category
Try changing to.
p.categoryname=((tbl_category)cb_category.SelectedValue).categoryname;
or
p.categoryname=cb_category.SelectedValue.categoryname;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.