Cordial greeting colleagues, it turns out that I have a string type array called nodes, in which I keep 4 strings, what I'm trying to do is that in the index view where I have a form, generate a select and fill it automatically with the values of this array, I've been hours in this, I can not find a way to do it.
//Arreglo donde guardaremos los nodos obtenidos en la lista
string[] nodos = new string[elementNames.Count];
foreach (var item in elementNames) //iterate over the list of elements
{
string elementName = item.Value;
nodos[i] = elementName;
//Contador para aumentar la posicion del arreglo
i++;
This code is found in a controller called Functions, in the actionresult index.
This is what I have in the view where I want to generate that select, and that the options are generated automatically with the values of that array.
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<title>Index</title>
</head>
<body>
<div class="container">
<form action="Funciones/nodos" method="post">
<label>Elija el nodo del que desea obtener parametros</label> <br />
<select>
<option value=""></option>
</select><br />
<button type="button" class="btn btn-primary">Enviar</button>
</form>
</div>
</body>
</html>
Could you give me an idea of how to do it?