Unable to Validate a RadzenDropDownDataGrid. Any help would be appreciated
<RadzenTemplateForm TItem="DriverRoute" Data="@MyRoute" Submit="@((DriverRoute args) => { OnSubmit(args); })">
<RadzenFieldset Text="Drivers Route">
<table>
<tr>
<td>
<RadzenLabel Text="Route Name" />
</td>
<td>
<RadzenTextBox Name="routeName" @bind-Value=@this.MyRoute.Name Style="margin-bottom:5px;width:200px;" />
<RadzenRequiredValidator Component="routeName" Popup="true" Text="Enter a name" Style="position: absolute;z-index:50;" />
</td>
</tr>
<tr>
<td>
<RadzenLabel Text="Driver" />
</td>
<td>
<RadzenDropDownDataGrid Name="driverList"
TValue="int"
Data=@(this.Drivers)
Style="width:200px"
TextProperty="Name"
ValueProperty="Id"
@bind-value="@this.MyRoute.DriverId">
<Columns>
<RadzenDropDownDataGridColumn Property="Id" Title="Id" Width="100px"/>
<RadzenDropDownDataGridColumn Property="Name" Title="Name" Width="200px"/>
</Columns>
</RadzenDropDownDataGrid>
<RadzenRequiredValidator Component="driverList" Popup="true" Text="Select a driver." Style="position: absolute;z-index:50;" DefaultValue="0" />
<RadzenNumericRangeValidator Component="driverList" Popup="true" Text="Select a driver." Style="position: absolute;z-index:50;" Min="1" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<RadzenButton ButtonStyle="ButtonStyle.Primary" Text="OK" Style="width: 120px" ButtonType="Radzen.ButtonType.Submit" />
</td>
</tr>
</table>
</RadzenFieldset>
</RadzenTemplateForm>
@code{
DriverRoute MyRoute { get; set; } = new DriverRoute();
DriverCollection Drivers { get; set; } = new DriverCollection();
void OnSubmit(DriverRoute route)
{
System.Diagnostics.Trace.WriteLine($"Route Name:{route.Name} Driver Id:{route.DriverId}");
}
public class DriverRoute
{
public int Id { get; set; }
public string Name { get; set; }
public int DriverId { get; set; }
}
public class Driver
{
public string Name { get; set; }
public int Id { get; set; }
}
public class DriverCollection : List<Driver>
{
public DriverCollection()
{
this.Add(new Driver()
{
Id = 100,
Name = "George Washington"
});
this.Add(new Driver()
{
Id = 200,
Name = "Thomas Jefferson"
});
this.Add(new Driver()
{
Id = 300,
Name = "John Adams"
});
this.Add(new Driver()
{
Id = 400,
Name = "Abraham Lincoln"
});
}
}
}