Im going to do my best to describe my issue, its hard to put into words.
On my page, I have a textbox and a button. I type a users name in the textbox and click the button to bring back all the users information.
Below this, I have a table being generated by a foreach loop of every role in my database that the user could possibly be in, with a 2 checkboxs next to it. The roles and textbox display even before the button is clicked.
When the users information comes back, whichever roles the user is in, I need to check those boxes.
It seems easy enough, I am just having a hard time trying to figure out how I am going to target each specific checkbox, because they are being created in a loop, not allowing me to give them specific ID's.
<table border="1" id="ApplicationRoles">
<thead>
<tr>
<th style="text-align:center" width="300">Role</th>
<th style="text-align:center" width="300">Category 1</th>
<th style="text-align:center" width="300">Category 2</th>
</tr>
</thead>
<tbody>
@foreach (var role in Model.appRoles)
{
<tr>
<td>
@Html.DisplayFor(modelItem => role.Name)
</td>
<td>
<input type="checkbox" />
</td>
<td>
<input type="checkbox" />
</tr>
}
</tbody>
</table>
Using javascript, I can check to see what roles the user is in, but how can I target a specific checkbox to check it(saying the user is in this role), without being able to give each one an ID?
Aucun commentaire:
Enregistrer un commentaire