I'm developing an application with HTML and C # in MVC standards, and in one of the menus I need to put a list of options in which the user will select what they want, that data comes from the database, so what I did was as follows:
I created a Model and there I created a list.
public class NotasFiscaisModel
{
public virtual string usuarioLogado { get; set; }
public virtual string dataUltimoLogin { get; set; }
public virtual string unidadeInicio { get; set; }
public virtual string unidadeFim { get; set; }
public virtual string dataInicial { get; set; }
public virtual string dataFinal { get; set; }
public virtual string nome { get; set; }
public virtual IList<NotasFiscaisModel> autorizados { get; set; }
}
With this, I make a select to popular my authorized list
foreach (DataRow linha in autoriz.RetornaAutorizados(LoginController._login.empresa).Rows)
{
NotasFiscaisModel nota = new NotasFiscaisModel();
nota.nome = linha["nome"].ToString();
_notas.autorizados.Add(nota);
}
Inside the HTML, I have an excerpt that lists the options via tag option:
<td>
<div class="col-xs-2" style="width:190px">
<div class="form-group">
<select class="form-control" id="sel1">
<option>Todos</option>
@foreach (var obj in Model.autorizados)
{
<option>@obj.nome</option>
}
</select>
</div>
</div>
</td>
This works, as it shows what is happening in the print below (do not call pros values, it is test base kkk):
Now I would like to pick which user you selected, returning to my Model, making the Controller have access to that content and to be able to do more operations, is there a way?