Hello,
i want to bind data to an autocomplete async.
The index.cshtml looks like this:
@(Html.Kendo().AutoCompleteFor(m => m.customerName) .DataTextField("customerName") .BindTo((System.Collections.IEnumerable)ViewData["customers"]) )
The controller like this:
public async Task<IActionResult> Index()
{
InitializeApiClient();
ViewData["customers"] = await GetCustomers();
return View();
}
private async Task<IEnumerable<CustomerShort>> GetCustomers()
{
Customers = new List<CustomerShort>();
List<Models.Customer> customer = await JupiterClient.Api.V1.Customer.GetAsync(x => x.QueryParameters = null);
foreach (var item in customer)
{
Customers.Add(new CustomerShort()
{
customerId = item.Id.ToString(),
customerName = item.Name + @" (" + item.Id.ToString() + @")"
});
if (Customers.Count > 999)
{
break;
}
}
return Customers.AsEnumerable();
}
When i start the web-app i get no error. But the client-data is empty:
What have i made wrong?
Kind regards
Jens