Last Updated: 26 Jul 2019 07:50 by ADMIN
Release 1.4.0
Created on: 15 Jul 2019 07:03
Category: DropDownList
Type: Bug Report
Validation is triggered immediately upon load when binding to nullable GUID

When bound to a nullable GUID, the DropDownList invokes validation and shows validation messages as soon as the view loads.

Expected: the same behavior as with nullable int - validation is to be triggered by the form submission or selection from the dropdown.

Worked as expected in 1.2.0.


@using Telerik.Blazor.Components.DropDownList
@using System.ComponentModel.DataAnnotations
<EditForm Model="@person" OnValidSubmit="@HandleValidSubmit">
    <DataAnnotationsValidator />
    <ValidationSummary />
    <p class="gender">
        Gender: <TelerikDropDownList @bind-Value="person.Gender" DefaultItem="@ddlHint"
                                   Data="@genders" TextField="MyTextField" ValueField="MyValueField">
        <ValidationMessage For="@(() => person.Gender)"></ValidationMessage>
    <button type="submit">Submit</button>
@code {
    // Usually the model classes would be in different files
    public class Person
        [Required(ErrorMessage = "Gender is mandatory.")]//the value field in the dropdown model must be null in the default item
        public Guid? Gender { get; set; }
    public class MyDdlModel
        //nullable so the default item can allow required field validation
        public Guid? MyValueField { get; set; }
        public string MyTextField { get; set; }
    Person person = new Person();
    MyDdlModel ddlHint = new MyDdlModel { MyValueField = null, MyTextField = "Gender" };
    IEnumerable<MyDdlModel> genders = new List<MyDdlModel>
        new MyDdlModel {MyTextField = "female", MyValueField = new Guid()},
        new MyDdlModel {MyTextField = "male", MyValueField = new Guid()},
        new MyDdlModel {MyTextField = "other", MyValueField = new Guid()},
        new MyDdlModel {MyTextField = "I'd rather not say", MyValueField = new Guid()}
    void HandleValidSubmit()