How to create "options" in Select from a spreadsheet?

Asked

Viewed 44 times

0

I wonder if it is possible to generate options dynamically in the selection by C#?

For example, I have my selection :

 <select id="Selecao_itens" multiple="multiple" runat= server  size="3" class="selection">
   <option value="Celula1 da planilha">Desejo criar esses options</option>    
</select>  

Thank you!!

  • What exactly is your question, explain your scenario better

1 answer

1


In the view I use so:

@Html.DropDownListFor(model => model.ID_Funcionalidade, controller.ListarFuncionalidade() as SelectList, "Selecione...", new { @class = "form-control" })

I create a method in the controller to list the data that comes from somewhere bring to the screen with the type SelectList.

Example:

public SelectList ListarFuncionalidade(object id = null)
{
    var funcionalidade = _IFuncionalidadeApplicationService.GetAllAsNoTracking().ToList();

    IList<FuncionalidadeViewModel> funcionalidadeViewModel = Mapper.Map<IEnumerable<Funcionalidade>, IList<FuncionalidadeViewModel>>(funcionalidade);

    return new SelectList(funcionalidadeViewModel, "ID", "Nome", id);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.