Maybe I'm going about this the wrong way but the model populating the AutoComplete has an Id and a Name. I display the Name but when the form is submitted I need to return the Id since it will bind to the property on the model.
Presently the AutoComplete is populated correctly when I start entering data, but when I submit the form, the widget has the red border meaning that it's not returning the int property type but the string type.
These are two of the AutoComplete properties on my model that I need to bind to:
Here is my Vendor AutoComplete widget:
Bottom line: I need to bind the Id of the selected value back to the controller, so I need to know how to return the Id from the AutoComplete widget and include it with the response.
Any help on this is appreciated.
Thanks.
Presently the AutoComplete is populated correctly when I start entering data, but when I submit the form, the widget has the red border meaning that it's not returning the int property type but the string type.
These are two of the AutoComplete properties on my model that I need to bind to:
[DisplayName(
"Vendor"
)]
public
int
? VendorId {
get
;
set
; }
[DisplayName(
"Category"
)]
public
int
CategoryId {
get
;
set
; }
@(Html.Kendo().AutoComplete().Name("Expense.VendorId")
.DataTextField("VendorName")
.Filter(FilterType.StartsWith)
.Placeholder("Type in a Vendor...")
.DataSource(dataSource =>
{
dataSource.Read(read => read.Action("_GetVendors", "Expense"));
})
)
Any help on this is appreciated.
Thanks.