I have a Blazor Page where i iterate over a list of Posts like this:
@for (int i = 0; i < blogposts.Count; i++)
{
<Blogpost blogpostData="@blogposts[i]" />
<br />
}
}
Inside of this Blogpost i set the Style of the Button depending on of the user Liked this post or not:
<RadzenButton Variant="Variant.Text" Click=@Upvote class="@upvotestyle" id="@upid"></RadzenButton>
When i now create a new Post and add the Post to my blogposts List, i call StateHasChanged(). But now my Buttons are no longer correctly Styled.
When i had the First Button styled Blue and i add a new Post on top the second Button should be blue. But its still the first!
I tried giving each button an own ID. But Blazor actually changes the ID, just like with the Buttons when i add another Post to the List, the first Post has the IDs from the Second one and so on.
Reloading the Page works. But thats obviously not a nice Solution.
Sorry i dont know how to accuratly describe my Problem i hope it is clear.