Column-Span in ASP.NET MVC View

2.7k views Asked by At
@foreach (var item in Model) {
    @if(ViewData["dropDown_"+item.Code] != null){
        if (item.Code == "1" || item.Code == "4")
        {
            <td>
                @Html.DropDownList("dropDown_"+item.Code+"_ListName", (IEnumerable<SelectListItem>)ViewData["dropDown_"+item.Code] ,new { style = "width: 100px; column-span: 2;" }) 
            </td>    
        }else{
            <td>
                @Html.DropDownList("dropDown_"+item.Code+"_ListName", (IEnumerable<SelectListItem>)ViewData["dropDown_"+item.Code] ,new { style = "width: 100px;" }) 
            </td>
            <td>
                Owner Preference: GREEN
            </td>
        }
    }
}

From the above code, there will be 4 rows of dropdownlist be generated. The question is how to make the first one and the last one to column span. Note that I've included column-span:2 in the style list, but it has no effect nor giving any errors. Please help.

enter image description here

1

There are 1 answers

0
Nilesh On BEST ANSWER

You need to set the colspan for the TD

  <td colspan="2">
    @Html.DropDownList("dropDown_"+item.Code+"_ListName", (IEnumerable<SelectListItem>)ViewData["dropDown_"+item.Code] ,new { style = "width: 100px;" }) 
   </td>