I have a of Hexes, buildings/improvments and NPC Hirelings. I would like to nest via a loop the Hexes, buildings/improvments and NPC Hirelings so that I can assign a hireling to a building that belongs to a Hex via a drop down. And once the Hireling is selected populate a label with some text and also remove/disable the hireling from all other drop down.
<table class="w-50">
@foreach (var hxs in HexName)
{
<tr>
<td colspan="2"><h3> @hxs.HexName Hex</h3></td>
</tr>
@foreach (var imps in Improvment) if (@hxs.HexName == imps.ImprovementHex)
{
<tr>
<td colspan="2">@imps.ImprovementName - @imps.ImprovementMaterial</td>
</tr>
@for (int i = 0; i <= 3; i++)
{
<tr>
<td class="p-3">
<select class="form-select">
<option />
@foreach (var hire in Hirelings)
{
<option value="@hire.HirelingId">@hire.HirelingName</option>
}
</select>
</td>
<td class="p-3"> <p>some text heere</p></td>
</tr>
}
}
}
</table>
@code {
private List<Improvements> Improvment = ImprovementsRepository.GetImprovements();
private List<MapHex> HexName = MapHexRepository.GetMapHex();
private List<Hireling> Hirelings = HirelingRepository.GetHirelings();
private string? TotalValue { get; set; }
}
I have tried using ChatGPT and Gemini to help create the code but I cannot get it to work.
AirshipPirate is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.