Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How do I make the input type radio so that it can be checked?

$
0
0

I have the problem that when I insert the check to the first one and then I insert another one and the check is passed to the new one that is entered and the idea is that it stays there in the first one that I entered.

method

private async Task GuardarModalDireccion(){    if (isEditDireccion)    {        dataDireccionGrid[dataDireccionForm.INDEX] = dataDireccionForm;    }    else    {        var splitDireccion = dataDireccionForm.CIUDANEID.Split("-");        if (splitDireccion.Length >= 3)        {            Direcciones direcciones = new Direcciones            {                CIUDANEID = splitDireccion[0].Trim(),                DIRECCION = $"{dataDireccionForm.DIRECCION}, {splitDireccion[1].Trim()}, {splitDireccion[2].Trim()}"            };            if(dataDireccionGrid.Count > 0){                direcciones.ESTADO = 0;            }            dataDireccionGrid.Add(direcciones);        }    }    await modalDireccion.HideAsync();    dataDireccionForm = new Direcciones();    StateHasChanged();}

blazor

<Tab Title="Direcciones"><Content><div class="d-flex flex-column w-100"><button type="button" class="btn btn-primary-custom mt-3" id="btnInsertarDireccion" style="width: max-content" @onclick="showModalInsertarDireccion"><i class="bi bi-plus-lg"></i> Insertar</button><div class="row w-100 mt-3 m-0"><div class="col-12 px-0">                     @if (dataDireccionGrid?.Count > 0)                     {<div class="list-group gap-2">                             @for (int i = 0; i < dataDireccionGrid.Count; i++)                             {                                 var item = dataDireccionGrid[i];                                 item.INDEX = i;<div class="list-group-item d-flex justify-content-between align-items-center"><div class="d-flex justify-content-start"><input type="radio" name="direccion" class="d-flex flex-row gap-1" value="@item.DIRECID" id="direccion-@i" checked="@(item.ESTADO == 1 ? "true" : "false")" /><label for="direccion-@i" class="ml-2">                                             @item.DIRECCION</label></div><div><button class="btn btn-sm btn-outline-secondary rounded my-1" @onclick="(e) => {showModalEditDireccion(item);}"><i class="bi bi-pencil-square "></i></button><button class="btn btn-sm btn-outline-secondary rounded" @onclick="(e) => {dataDireccionGrid.Remove(item);}"><i class="bi bi-trash"></i></button></div></div>                             }</div>                     }                     else                     {<p>No se han encontrado Direcciones.</p>                     }</div></div></div></Content></Tab>

help me there in the coding of the check I work with a status 1 and 0 but I have this little problem that every time I enter one it always puts the check on the one that is entered new.

help with this problem please


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>