0

为数据绑定标签条设置标签内容时遇到问题。我找到了一个如何使用 webforms 语法的示例,但无法成功将其转换为剃刀:

这是来自here的webforms语法:

 .BindTo(Model,
(item, navigationData) =>
{
    item.Text = navigationData.Text;
    item.ImageUrl = navigationData.ImageUrl;

    item.Content = () =>
    {%>
                        Some random content I want to appear
                <% };
})

这是我在 Razor 中尝试的方法:

@(Html.Kendo().TabStrip()
    .Name("OrderDetailsTabs")
    .BindTo(Model, (item, model) =>
    {
        item.Text = "Part: " + model.WOHdr.OrderDetailId; // tab text
        item.Content = () =>
            {
                (@<text>
                    Test @(model.WOHdr.Id)
                </text>);
            };

这会产生错误:

A local variable named 'item' cannot be declared in this scope because it would give a different meaning to 'item', which is already used in a 'parent or current' scope to denote something else
4

1 回答 1

0

您必须使用 .InlineTemplate...而不是 .Content

tab.Template.InlineTemplate = 
        @<text> 
            @(Html.EditorFor(model => tabModel, "WorkOrder", tabModel))
        </text>;
于 2013-07-17T13:37:36.300 回答