RajeshKumar
New member
- Joined
- Nov 23, 2022
- Messages
- 1
- Programming Experience
- 1-3
I have one ParentComponent and one ChildComponent. The ChildComponent contain RadzenDropDown is not validating when click on submit button from ParentComponent .
ParentComponent.razor:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
ChildComponent.razor:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I have tried to implementing certain properties such as ValueExpression and FieldIdentifier from here and here But I am not getting.
	
		
			
		
		
	
				
			ParentComponent.razor:
			
				C#:
			
		
		
		<RadzenTemplateForm TItem="ProductModel" Submit="OnValidSubmit" Data=@model>
 <DataAnnotationsValidator />
   <ChildComponent @ref="productSelection" />
  </RadzenTemplateForm> 
@code{
    private async void OnValidSubmit()
    {
        if (productSelection.idCategory?.Any() == true)
        {
            //save the checked items.
        }
        else
        {
            //show validation message.
        }
    }
}ChildComponent.razor:
			
				C#:
			
		
		
		<RadzenDropDown class="form-control" placeholder="Select Category"
                        AllowClear="true"
                        AllowFiltering="true"
                        Multiple="true"
                        FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
                        TextProperty="Name"
                        ValueProperty="Id"
                    @bind-Value=@idCategory
                    Data = @_listCategory
                    Name="CategoryName"
                        Change=@(args => onProductsChange(args)) />
                    <RadzenRequiredValidator style="color:red; font-weight:bold;position: absolute;" Component="CategoryName" Text="Category is Required" />
    @code{
    public IEnumerable<string> idCategory{ get; set; } = new List<string>();
    IList<string> _listCategory;
}I have tried to implementing certain properties such as ValueExpression and FieldIdentifier from here and here But I am not getting.
 
	 
 
		 
 
		