0

We all know that this works.

 @Html.DropDownListFor(m => m.SelectedProvisionalAward, Model.PreviousProvisionalAwardDecisions, new { style = "width: 250px;" })

But how do we make the something like this

   @{var width = @Model.PreviousProvisionalAwardDecisions.FirstOrDefault().Text.Length; }
   @Html.DropDownListFor(m => m.SelectedProvisionalAward, Model.PreviousProvisionalAwardDecisions, new { style = "width:"+ @width + "px;" })

What I want to achieve is width of the dropdown list extended to fill the full text displayed inside it. The obvious problem with this is that the length variable for a text with 42 symbols will output 42 but the width required to display that will be probably around 260px. Please assume that all items in the select list have the same length.

0 Answers0