Grid binding ala asp:repeater

18 views
Skip to first unread message

ashr

unread,
Oct 5, 2011, 8:50:13 AM10/5/11
to mvccontrib-discuss
Hi guys

I'd like to be able to use model binding inside the grid. Is this a
feature that you might be adding or should I rather look at other
solutions like partial views in a loop ?

Example:
@Html.Grid(Model.ImmovableProperty).Columns(
column =>
{
column.Custom(
@<text>
<div id="assetForm">
<fieldset>
<div id="assetFormRow">
<label for="assetTypeDropdown">Asset type</label>
@Html.DropDownList("typeOfAssetIdDropdown" +
@item.assetDetail.id.ToString(), new SelectList(Model.TypeOfAssetData,
"Key", "Value", @item.assetDetail.typeOfAssetId))
@Html.ValidationMessage("typeOfAssetId")
</div>
<div id="assetFormRow">
<input type="submit" value="Edit" name="editClient1" />
</div>
</fieldset>
</div>
</text>
);
}).Attributes(@class => "", @id => "")

The code above works fine, but I can't do *For model binding methods
like @Html.DropdownListFor and .TextboxFor etc. So my model is not
bound to the form and I cannot get changed values back to my
controller in an easy to use non-spaghetti way.

Thanks in advance, I hope I was clear enough.
Reply all
Reply to author
Forward
0 new messages