My Kendo Comboxbox server binding is not working
This is my View
@(Html.Kendo().ComboBox()
.Name("cbxState")
.HtmlAttributes(new { style = "width:150px" })
.Text("Select State")
.DataTextField("Code")
.DataValueField("Code")
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("cbx_read", "Home");
})
.ServerFiltering(true);
})
)
This is my Controller
public ActionResult cbx_read([DataSourceRequest]DataSourceRequest request)
{
using (var northwind = new Connection())
{
IQueryable<LostDayDetail> Customers = northwind.LostDayDetail;
DataSourceResult result = Customers.ToDataSourceResult(request, Customer => new CustomerDetail
{
Code = Customer.Code,
Name = Customer.Name,
Days = Customer.Days
});
return Json(result);
}
}
When I click on Combobox, it calls cbx_read function and it gets all 12 rows of data from database table. but when contol comes back to view, the combobox is blank.
Please help me
This is my View
@(Html.Kendo().ComboBox()
.Name("cbxState")
.HtmlAttributes(new { style = "width:150px" })
.Text("Select State")
.DataTextField("Code")
.DataValueField("Code")
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("cbx_read", "Home");
})
.ServerFiltering(true);
})
)
This is my Controller
public ActionResult cbx_read([DataSourceRequest]DataSourceRequest request)
{
using (var northwind = new Connection())
{
IQueryable<LostDayDetail> Customers = northwind.LostDayDetail;
DataSourceResult result = Customers.ToDataSourceResult(request, Customer => new CustomerDetail
{
Code = Customer.Code,
Name = Customer.Name,
Days = Customer.Days
});
return Json(result);
}
}
When I click on Combobox, it calls cbx_read function and it gets all 12 rows of data from database table. but when contol comes back to view, the combobox is blank.
Please help me