Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have two html page. First page contain 7 and second page also contains same 7 dropdown. Here only different is, if first page passing a parameter like show only 4 dropdown in the second page then should show only 1 to 4 dropdown in the second html page. Otherwise 6, then only show 1 to 6.

How can I implement this using c# code because I am using Blazor technology ?

What I have tried:

Can I use like:-
C#
@if (frstPageDropDownPageNo == 5)
{
 <RadzenDropDown1 />
 <RadzenDropDown2 />
 <RadzenDropDown3 />
 <RadzenDropDown4 />
 <RadzenDropDown5 />
}
else if (frstPageDropDownPageNo == 2){
<RadzenDropDown1 />
 <RadzenDropDown2 />
}
.
.
.
Posted
Updated 7-Nov-22 18:46pm
v2

1 solution

I am a bit rusty on my Blazor and only took a quick look at the Radzen components for this, but what I would do is create a component that can have multiple drop-downs based on a parameter passed to it like so:

Razor
<h3>MultipleDropdowns</h3>


@{
    while(dropDownCount < DropDownAmount) {
        <h5>Dropdown @(dropDownCount+1)</h5>
        <Radzen.Blazor.RadzenDropDown TValue="string"/>
        dropDownCount++;
    }
}


@code {
    private int dropDownCount = 0;

    [Parameter]
    public int DropDownAmount { get; set; } = 0;

}


This is very basic but a good starting point. You could then use this component like so:

Razor
<div>
    <MultipleDropdowns DropDownAmount="5"/>
</div>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900