'DataTarget to 'editPage' pass to edit page 'edit.cshtml'
I recently started learning Razor pages so please bear with me....I have an index.cshtml razor page that displays a database data into a table. each row has an edit button that targets a model page 'editpage' . how will i pass or call the target-page 'editpage' from my index.cshtml to my edit.cshtml page that has a modal view.
<---Index.cshtml--->>
@foreach ( var item in Model.Ceding ) {
<tr>
<td>@item.FirstName</td>
<td>@item.MiddleInitial</td>
<td>@item.LastName</td>
<td>@item.Gender</td>
<td>@item.DateofBirth</td>
<td>@item.CedingCompany</td>
<td>@item.PlanEffectiveDate</td>
<td>@item.SumAssured</td>
<td>@item.ReinsuredNetAmount</td>
<td>@item.Status</td>
<td>
<div class="form-button-action">
<button type="button" data-toggle="modal" title="" class="btn btn-link btn-simple-primary btn-lg" data-target="#editPage"><a class="fa fa-edit" asp-route-id="@item.Id"></a>
</button>
<button type="button" data-toggle="tooltip" title="" class="btn btn-link btn-simple-danger" data- original-title="Delete"><i class="fa fa-times"></i>
</button>
</div>
</td>
</tr>
}
<---Edit.cshtml--->>
<div class="modal fade bd-example-modal-lg" id="editPage" tabindex="-1" role="dialog" aria- labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="display-5" id="exampleModalLabel">EDIT DETAILS</h2>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
</div>
</div>
Controller:
public IEnumerable<Cedants> Ceding { get; set; }
public IndexModel( AppDbContext db )
{
_db = db;
}
public void OnGet(int id)
{
Ceding = _db.dbo_life.ToList(); //retrieves data in database
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
