Get a default value in a select mvc 5

0

I have created a partial view in which a <select></select> object is filled from a sql server database by a for each . The values they take for example are:

  

1 Cleaning items

     

2 Hardware articles

     

3 Fruits and Vegetables ... etc

So far this is all fine, but when I create another view and call this select I can not put a default value ... The view that I created brings the data of an article as its code, name, price and type of article (that appear in the list select ) ... I need that when I call an article the type to which it belongs is selected from this list automatically this is the code with which I call the list

@Html.Action("BuscarArticuloLinea", "ArticuloLinea", New With 
{.htmlAttributes = New With {.value = IdArticuloLinea}})

Thanks for your help.

    
asked by edusito87 07.12.2017 в 05:36
source

1 answer

-1

You can include the html attribute selected to the element you want by default.

<option selected="selected">
 3
</option>
    
answered by 07.12.2017 в 16:49