DropDownList all values are undefined values

1 Answer 115 Views
DropDownList
Vladimir
Top achievements
Rank 1
Iron
Vladimir asked on 16 Feb 2023, 04:20 PM
Hello. I am testing the product. It looks good but I found the first problem and could not resolve it. 

I have a dropdown list 
<kendo-dropdownlist name="customer" style="width:100%"
                                datatextfield="Text"
                                datavaluefield="Value">
                <datasource type="DataSourceTagHelperType.Custom">
                    <transport>
                        <read url="@Url.Action("GetCustomers", "Home")" />
                    </transport>
                </datasource>
            </kendo-dropdownlist>

I have a method

public JsonResult GetCustomers(string text)
        {
            //var customers = _context.Customers.ToList();

            var color_data = new List<SelectListItem>()
            {
                new SelectListItem() {
                    Text = "Black",
                    Value = "1"
                },
                new SelectListItem() {
                    Text = "Orange",
                    Value = "2"
                },
                new SelectListItem() {
                    Text = "Grey",
                    Value = "3"
                }
            };

            return Json(color_data);
            
        }
But the result is that I have three values in dropdown list but all are with text undefined. 
I have tried different scenarios... getting the data from DB or filling the static data like in this example but every time I get three items but undefined in the control...
The object color_data is correctly filled and has all three values...
Thank you for your help. 


1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir
Top achievements
Rank 1
Iron
answered on 17 Feb 2023, 11:03 AM

Hi I have found the solution:

DropDownlist - All options are undefined (Razor Pages) in UI for ASP.NET Core | Telerik Forums

Thank you for your help. Vladimir.

Tags
DropDownList
Asked by
Vladimir
Top achievements
Rank 1
Iron
Answers by
Vladimir
Top achievements
Rank 1
Iron
Share this question
or