This is a migrated thread and some comments may be shown as answers.

[Solved] DetailView and "@Html.LabelFor & EditorFor"

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FinallyInSeattle
Top achievements
Rank 1
FinallyInSeattle asked on 29 Sep 2011, 09:26 PM
Using Razor syntax.

Is there a way to add @Html.LabelFor/EditorFor statements into a DetailView?  There doesn't seem to be a syntax that I've found that works properly and I haven't found anything similar in your samples.

Something like below
.DetailView(detailView => detailView.Template(p =>
{
    Html.Telerik().TabStrip()
        .Name("TabStrip_" + p.LineItemNumber.ToString())
        .SelectedIndex(0)
        .HtmlAttributes(new {style = "width:800px"})
        .Items(items =>
        {      
            items.Add().Text("Overrides").Content(
                @<div>
                    @Html.LabelFor(p => p.SalesOrderLineItem.BillToPCN)
                    @Html.EditorFor(p => p.SalesOrderLineItem.BillToPCN)
                </div>);
        }).Render();
 
}

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 30 Sep 2011, 12:39 PM
Hello Lori,

I believe the following template should work for you:
.Content(
    @<text>
        <div>
        @Html.LabelFor(m => p.SalesOrderLineItem.BillToPCN)
        @Html.EditorFor(m => p.SalesOrderLineItem.BillToPCN)
        </div>
    </text>                           
);


Best wishes,
Nikolay Rusev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
FinallyInSeattle
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or