I need to render a label and a text input at each row in a Grid.Mvc control. Each row can have a diferente label and control according to row type.
I can render html controls using the htmlHelper, but how can i create an div control with a laber and a text input?
Here is were i go so far:
@Html.Grid(Model.WFMaster.Activities).Columns(columns =>
{
columns.Add().Titled("Parameter").Sanitized(false).Encoded(false).RenderValueAs(a =>
{
if ...
//Stuck here. I can't create an div and add controls to it.
return Html.TextBox("value");
});
});
For that output, you can make use of overload of RenderValueAs that accepts Ihtmlstring. Here is the example.
@Html.Grid(Model.WFMaster.Activities).Columns(columns =>
{
columns.Add().Titled("Parameter").Sanitized(false).Encoded(false).RenderValueAs(a =>
new HtmlString
(
<div>
<input type="text" name="fname"><br>
<label for="lastname">Lastname</label>
</div>
)
);
});