Razor - @ Html.DropDownList with dynamic name

0

I would like to concatenate the ID that I get from @Model in the string of the name property of Dropdownlist because I would like to treat them dynamically.

I try to do @Html.DropDownList ("Name" + @ Model.Id) and it does not work.

How could I do it?

    
asked by anonymous 31.07.2014 / 20:01

1 answer

2

Do this in your Model:

public string ConcatenarNome 
    {
        get
        {
            return string.Format("Nome{1}", Id);
        }
    }

And then in View:

@Html.DropDownList(@Model.ConcatenarNome) 
    
31.07.2014 / 20:59