user1405195
user1405195

Reputation: 1681

Editor Template to display checkboxes in table

I have an editor template displaying checkboxes in a table. Using the code below, all checkboxes will be rendered on a single row. Can anybody suggest how to render the checkboxes three per row?

Editor Template

@model AssignedBusAreaData
@using MOC.ViewModels

<td>
    @Html.HiddenFor(model => model.BusinessAreaID)    
    @Html.CheckBoxFor(model => model.Assigned)
    @Html.DisplayFor(model => model.BusinessAreaName)
</td>

View

    <div class="editor-label">
        @Html.LabelFor(model => model.BusinessAreas)
    </div>
    <div class="editor-field">
        <table>
            <tr>
                @Html.EditorFor(model => model.BusinessAreas)
            </tr>
        </table>
    </div>

Upvotes: 0

Views: 895

Answers (1)

Amit
Amit

Reputation: 15387

try this

<table>
  <tr>
   <td>
    @Html.HiddenFor(model => model.BusinessAreaID)    
    @Html.CheckBoxFor(model => model.Assigned)
    @Html.DisplayFor(model => model.BusinessAreaName)
   </td>
 </tr>
</table>

View

<div class="editor-label">
    @Html.LabelFor(model => model.BusinessAreas)
</div>
<div class="editor-field">
    <table>
        <tr>
          <td>
            @Html.EditorFor(model => model.BusinessAreas)
          </td>
        </tr>
    </table>
</div>

Upvotes: 1

Related Questions