Hi Boucourt
I can not put a form for each line because I can not put <form> inside a <tr>
It can work fine in my side. Here is the whole working demo.
Model
public class TimeLinesEpisodeEntitiesDto
{
public int TimeLineId { get; set; }
public string EntityType { get; set; }
public int OwnerId { get; set; }
public double Start { get; set; }
public double End { get; set; }
}
public class RequestViewModel
{
public SimulatedResponse SimulatedResponse { get; set; }
public IEnumerable<TimeLinesEpisodeEntitiesDto> TimelinesEpisodeEntities { get; set; }
}
public class SimulatedResponse
{
public double EndSecs { get; set; }
// Other properties related to the simulation can be added here
}
View
@model RequestViewModel
<tbody>
@{
int i = 0;
double actualSync = Model.SimulatedResponse.EndSecs;
}
@foreach (TimeLinesEpisodeEntitiesDto ptl in
@Model.TimelinesEpisodeEntities)
{
i++;
<form method="post" action="@Url.Action("CorrigeUnTimeLine", "Episode")">
<tr>
<td style="width:15%">
@if (actualSync > ptl.Start && actualSync < ptl.End)
{
<span class="SelectedTimeLine ml">@ptl.EntityType : @ptl.OwnerId</span>
}
else
{
<span>@ptl.EntityType : @ptl.OwnerId</span>
}
</td>
<td style="width:15%">
<input type="hidden" name="TimeLineId" value="@ptl.TimeLineId" />
<input type="number" class="form-input flex-1" style="background-color: #B0C4DE;" readonly value="@ptl.TimeLineId">
</td>
<td style="width:15%">
<input type="number" class="form-input flex-1" name="Start" value="@ptl.Start">
</td>
<td style="width:15%">
<input type="number" class="form-input flex-1" name="End" value="@ptl.End">
</td>
<td style="width:10%">
<button type="submit" class="icon" title="Edit">
<img height="25px" width="25px" float="inline-end" src="~/Icon/Edit.png" />
</button>
</td>
</tr>
</form>
}
</tbody>
Controller
[HttpPost]
public IActionResult CorrigeUnTimeLine(int timeLineId, double start, double end)
{
// Update the timeline record in the database
}
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,
Rena