I want to provide Custom datasets alongside of added dropdown that will be bind by DynamicComponent as per my need.
How to achieve this using RenderFragment?
I've tried but it's not worked yet I'm working on multiple components on the same page with that dropdown all are rendered using DynamicComponent.
Please share some example codes, if possible, that will be helpful.


Jayraj ChhayaRank #304 · 8.2K reputationPosted Jun 6, 2024, 7:51 AM EDT
To render a RadzenDropdown with custom datasets using DynamicComponent in Blazor, you can create a RenderFragment that defines the dropdown's structure and behavior.
@code { List customData = new List { "Option 1", "Option 2", "Option 3" }; RenderFragment RenderDropdown() => builder => { builder.OpenComponent(0, typeof(RadzenDropdown)); builder.AddAttribute(1, "Data", customData); builder.CloseComponent(); }; }In this example,
customDatarepresents your custom dataset. You can then useRenderDropdown()within your DynamicComponent to render the RadzenDropdown with the custom dataset. Ensure that the necessary Radzen components are imported and configured in your project for this to work seamlessly.Vaishali VishwakarmaRank #975 · 2.1K reputationPosted Jun 6, 2024, 9:00 AM EDT
Thanks, Jayraj I want this RenderFragment on a button click, but it's not working i have tried to debug it also but not getting it on that function.
RenderDropdown(field))" Icon="+" Text="Add Data" title="Add data" /> //field is my form model property that will contains attributes related to a form field e.g. Label, Id, Class...etc //function on same .razor page @code RenderFragment RenderDropdown(FormField formField) => builder => { builder.OpenComponent(0, typeof(RadzenDropDown)); builder.AddAttribute(1, "Data", typeOfRegistrationList); builder.CloseComponent(); };