4
votes

I'm trying to make a Telerik Kendo grid of audit records, with a sub grid presenting the details of each main record.

I'm getting a syntax error which I don't understand.

@model IEnumerable<AuditRecord>

@(Html.Kendo().Grid(Model)
    .Name("AuditGrid")
    .DetailTemplate(auditrec =>
    {
        @<text>
        @(Html.Telerik()
             .Grid(auditrec.Details)
             .Name("Detail_" + auditrec.ID.ToString()))
        </text>
    }))

Error message follows, with the line @<text> flagged as the source of the error:

CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

This is modeled after the Telerik example here.

What am I getting wrong about the Razor syntax? The <% syntax isn't working for me, either.

1
try <text> without the Razor @Dave Alperovich
That moves the error to the next line: CS1646: Keyword, identifier, or string expected after verbatim specifier: @. If I remove the @ on that line, the error moves back up one line and reads: CS1525: Invalid expression term '<'user47589
I dont think you need the @ identifier inside the block. try removing it.Dave Alperovich
It just moves the error back up one line and says the < is invalid. This is so confusing.user47589

1 Answers

1
votes

Nesting like this is tricky, but try this syntax

@{Html.Kendo().Grid(Model)
    .Name("AuditGrid")
    .DetailTemplate(auditrec =>
    {
        @<text>
        @{@Html.Telerik()
             .Grid(auditrec.Details)
             .Name("Detail_" + auditrec.ID.ToString())
        }
        </text>
    })
}