2013-08-28 39 views
0
@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> 
     } 
    } 
} 

从上面的代码中,将会生成4行dropdownlist。问题是如何使第一个和最后一个列跨度。请注意,我在样式列表中包含了column-span:2,但它没有效果也没有提供任何错误。请帮忙。ASP.NET MVC视图中的列跨度

enter image description here

回答

1

您需要设置合并单元格的TD

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