ASP.NET MVC视图中的列跨度

时间:2013-08-28 02:55:10

标签: asp.net-mvc asp.net-mvc-4 razor html-helper columnspan

@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行下拉列表。问题是如何制作第一个和最后一个到列跨度。请注意,我在样式列表中包含了column-span:2,但它没有任何效果,也没有任何错误。请帮忙。

enter image description here

1 个答案:

答案 0 :(得分:2)

您需要为TD

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