简体   繁体   中英

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'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" class="form-control">
  <option value="null"> Escolha um Ap ou todos</option>
  <option value="todos"> Todas as zonas </option>
    @foreach(var i in Model.Zones)
    {
         <option value=@i.zone_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; }

    }

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

<select asp-for="ap" class="form-control" multiple>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM