So I just created a .NET 6 ASP.NET Core Web App (Razor Pages), added all telerik stuff according to the instructions (NuGet Packages, scripts and styles in _Layout.cshtml, @addTagHelper-s in _ViewImports.cshtml), and HTMLHelpers are rendering correctly. However, when I provide a data source to the DropDownList or ComboBox, all options show up as undefined.
Telerik version: 2022.2.621. Bootstrap: V5.
Here's the code for DropDownList:
Index.cshtml
@page
@model IndexModel
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()
@{
ViewData["Title"] = "Home page";
}
--------------------------------------------------------------------------------
<div class="text-center">
<h1 class="display-4">Welcome</h1>
@(Html.Kendo().DropDownList()
.Name("MyDropdownn")
.DataTextField("Text")
.DataValueField("Value")
.HtmlAttributes(new { style = "width:300px;" })
.AutoBind(false)
.Filter(FilterType.Contains)
.DataSource(ds => ds
.Custom()
.Transport(transport => transport
.Read(r => r
.Url("/Index?handler=Sports")
))
.ServerFiltering(false)
)
)
</div>
Index.cshtml.cs
public JsonResult OnGetSports()
{
var allSports1 = db.Sports.Where(x => x.SportID > 0).Select(x => new DropDownModel
{
Text = x.Name,
Value = x.SportID
}).ToList();
return new JsonResult(allSports1);
}
Proof that the data isn't empty/undefined
DropDownModel.cs (DropDownModel class)
public class DropDownModel
{
public int Value { get; set; }
public string Text { get; set; } = String.Empty;
}
I've tried restarting everything, double-checking everything but nothing helped. Is there a bug with this version of telerik, is something incompatible with ,NET 6 or Bootstrap 5? Or am I doing something wrong?