Home > Enterprise >  I have a a list of Aps and i need to select one or multiple elements of that list in asp.net with c#
I have a a list of Aps and i need to select one or multiple elements of that list in asp.net with c#

Time:04-12

I'm developing a school project with asp.net core mvc and i have a list of zones and i need to select from that list multiple elements, now i'm using a select like that

<div  style="margin-bottom:2%;">
<p>Escolha os AP's que quer verificar</p>
<div style="margin-bottom:2%; width:70%; text-align:center; text-align-last:center ">
<select asp-for="ap" >
  <option value="null"> Escolha um Ap ou todos</option>
  <option value="todos"> Todas as zonas </option>
    @foreach(var i in Model.Zones)
    {
         <option [email protected]_id> @i.zone_name </option>
    }
  </select>
 </div
</div> 

But when i use that i can´t select multiple options, soo exists any way to i can do that?? Even if i have to use something different.

1

Thats the zone Structure

    public class L_Zone
    {
        public short zone_id { get; set; }
        public string? zone_name { get; set; }
        public decimal latitude { get; set; }
        public decimal longitude { get; set; }
        public DateTime? ts { get; set; }
        public bool Active { get; set; }
        public short geolocation_id { get; set; }

    }

CodePudding user response:

Add the multiple boolean attribute to the select tag as follows:

<select asp-for="ap"  multiple>
  • Related