Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用kendo中绑定的网格列将字符串从视图(Razor)传递到编辑器模板_C#_Asp.net Mvc_Razor_Kendo Ui_Kendo Grid - Fatal编程技术网

C# 使用kendo中绑定的网格列将字符串从视图(Razor)传递到编辑器模板

C# 使用kendo中绑定的网格列将字符串从视图(Razor)传递到编辑器模板,c#,asp.net-mvc,razor,kendo-ui,kendo-grid,C#,Asp.net Mvc,Razor,Kendo Ui,Kendo Grid,我想使用剑道网格列绑定将字符串从视图(razor)传递到编辑器模板。我正在使用上载文件(编辑器模板)。我尝试使用“EditorViewdata()”传递字符串,但它不起作用 我的编辑器模板是: @model string @(Html.Kendo().Upload() .Name("FileUrl") .Events(events => { events.Select("onSelectFile"); events.Success(

我想使用剑道网格列绑定将字符串从视图(razor)传递到编辑器模板。我正在使用上载文件(编辑器模板)。我尝试使用“EditorViewdata()”传递字符串,但它不起作用

我的编辑器模板是:

@model string

@(Html.Kendo().Upload()
    .Name("FileUrl")
    .Events(events =>
    {
        events.Select("onSelectFile");
        events.Success("onUploadSuccessFile");
    })
    .Messages(messages =>
    {
        messages.Select("Upload");
    })
    .Enable(true)
    .Async(async =>
    {
        async.Save("SaveFile", "Products");
        async.Remove("DeleteFile", "Products");
        async.AutoUpload(true);
    })
    .Multiple(false))
我的列绑定为:

columns.Bound(e => e.FileUrl).EditorTemplateName("FileUrl").Title("File");

我怎么做

使用
编辑器查看数据
是最简单的方法。确保您是这样使用它的:

columns.Bound(e => e.FileUrl).EditorTemplateName("FileUrl")
                             .EditorViewData(new { stringName = stringValue })
                             .Title("File");

然后在编辑器模板中,您可以通过调用
ViewData[“stringName”]

来获取值,使用
EditorViewData
是最简单的方法。确保您是这样使用它的:

columns.Bound(e => e.FileUrl).EditorTemplateName("FileUrl")
                             .EditorViewData(new { stringName = stringValue })
                             .Title("File");

然后在编辑器模板中,您可以通过调用
ViewData[“stringName”]

来获取值。我有一个列作为:columns.Bound(c=>c.PartNo),现在我想使用“EditorViewData”将“PartNo”的值发送到编辑器模板。我使用下面的代码发送它,但它总是显示为null。columns.Bound(e=>e.FileUrl).EditorTemplateName(“FileUrl”).EditorViewData(新的{stringName=“#=零件号#“}).Title(“文件”);在控制器中,检查您的模型并查看
PartNo
的值是否为空。如果为空,则将其值更改为空字符串。在将模型传递到视图之前,请执行此操作。“PartNo”值没有null值,它始终不可为null。我有一个列作为:columns.Bound(c=>c.PartNo),现在我想使用“EditorViewData”将“PartNo”的值发送到编辑器模板。我使用下面的代码发送它,但它总是显示为null。columns.Bound(e=>e.FileUrl).EditorTemplateName(“FileUrl”).EditorViewData(新的{stringName=“#=零件号#“}).Title(“文件”);在控制器中,检查您的模型并查看
PartNo
的值是否为空。如果为空,则将其值更改为空字符串。在将模型传递到视图之前执行此操作。“PartNo”值没有null值,它始终不可为null。