'How to retrieve values from @Html.DisplayTextFor when @Html.CheckBox is checked?

I have made the following form but have some difficulties with retrieving values. The problem that I cannot seem to overcome is checking whether the @Html.CheckBox("check", new {@type="checkbox", @id="CheckBox"}) is checked or not and according to that save the @Html.DisplayTextFor(m => m.DLLsFull[i][0]) in a List. I was wondering if someone could guide me unto the right path / help me out to find out how I can do this.

Munch appreciated!

<div class="text-center">
    <h1 class="display-6">Testsets per DLL</h1>
    @using (Html.BeginForm("TestsetsPerDLL", "GenerateOverview", FormMethod.Post, new {@class = "d-flex flex-column"}))
    {
        <h1 class="w-50 text-start align-self-sm-center fw-lighter fs-5">Vul de output type in:</h1>
        <table class="w-50 align-self-sm-center">
            <tr>
                <td>@Html.HiddenFor(m => m.Overview)</td>
                @if (@ViewBag.OutputTypes == null || @ViewBag.OutputTypes.Count == 0)
                {
                    <td>@Html.TextBoxFor(m => m.Output, new { @class = ""})</td>
                }
                else
                {
                    <td>@Html.DropDownListFor(m => m.Output, new SelectList(@ViewBag.OutputTypes), "Selecteer een type", new {@class = " w-100"})</td>
                }
            </tr>
        </table>
        <partial name="_pager" model="Pager"/>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
        <table class="table table-striped">
            @if (Model.DLLsFull is not null)
            {
                <tr>
                    <th>DLL</th>
                    <th>Titel</th>
                    <th>Beschrijving</th>
                    <th>Geselecteerd</th>
                </tr>
                @for (int i = 0; i < Model.DLLsFull.Count; i++)
                {
                    <tr>
                        <td class="m-t-1 text-start">@Html.DisplayTextFor(m => m.DLLsFull[i][0])</td>
                        <td class="m-t-1 text-start">@Html.DisplayTextFor(m => m.DLLsFull[i][1])</td>
                        <td class="m-t-1 text-start">@Html.DisplayTextFor(m => m.DLLsFull[i][2])</td>
                        <td class="m-t-1 text-center">@Html.CheckBox("check", new {@type="checkbox", @id="CheckBox"})</td>
                    </tr>
                }
            }
        </table>
        <input class="btn btn-outline-primary" type="submit" value="Genereer" />
    }
</div>````


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source