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;