سؤال

@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

هل كانت مفيدة؟

المحلول

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>   
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top