Hi @ahmed salah
How to access
userModel.Branches
Branch List from page model to view
Since in the AddUser.cshtml.cs
file, the property name is userModel
, to access the branches, you should also access the data from the userModel
.
Try to use the following code:
<select id="branch-select" name="SelectedBranchId" class="form-control" style=" margin-left:10px;font-size:15px;font-family: 'Open Sans' , sans-serif;font-weight: bold;">
<option value="">-- Select Branch --</option>
@foreach (var branch in Model.userModel.Branches)
{
<option value="@branch.iBranchCode">@branch.vBranchDesc</option>
}
</select>
The output as below:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion