I have a component in Blazor that takes a parameter "TItem" which can be any object:
Employees.razor
@page "/Employees"
<GenericGrid TItem="Employee" MaintainState="true"></GenericGrid>
@code
{
}
The above component is a wrapper for a Telerik grid component. This way, I can use the same grid component to display data from different objects, depending on which object I pass onto it (Employee, Customer, etc.)
GenericGrid.razor (only showing relevant code)
@typeparam TItem
...grid layout...
<GridToolBar>
<GridCommandButton Icon="add">New @typeof(TItem).Name</GridCommandButton>
</GridToolBar>
...rest of grid layout...
@code {
...
[Parameter]
public TItem Entity { get; set; }
...
When the button gets clicked, I want to send the user to another page. This page should contain a form for creating whatever object I pass onto it. However, the first obstacle is being able to send the object to another page in the first place. Route parameters only support things like strings and integers, so that's not an option.
I found the following StackOverflow question: c# blazor how to pass a List to a page. The accepted solution looks like a viable option, but I can't wrap my head around how to implement this for my case.