2013-08-28 80 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>