Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.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# 使用列表<&燃气轮机;作为模型-asp.net mvc_C#_Javascript_.net_Asp.net Mvc 2 - Fatal编程技术网

C# 使用列表<&燃气轮机;作为模型-asp.net mvc

C# 使用列表<&燃气轮机;作为模型-asp.net mvc,c#,javascript,.net,asp.net-mvc-2,C#,Javascript,.net,Asp.net Mvc 2,因此,我返回一个视图,其中包含一个列表作为模型: List<Indications.Analysis.PrepaymentResult> resultsList = Indications.Analysis.PrepaymentResult.GetPrepaymentResult(indication.Model.Trx, indication.Model.ShockBpsDropList.Value, indication.Model.ShockIncrements.Value);

因此,我返回一个视图,其中包含一个列表作为模型:

List<Indications.Analysis.PrepaymentResult> resultsList = Indications.Analysis.PrepaymentResult.GetPrepaymentResult(indication.Model.Trx, indication.Model.ShockBpsDropList.Value, indication.Model.ShockIncrements.Value);
return View(@"~\Views\Indications\TermSheetViews\Swap\PrePayment.aspx", resultsList);
List resultsList=Indications.Analysis.premmedmentresult.getpremmedmentresult(indication.Model.Trx,indication.Model.ShockBpsDropList.Value,indication.Model.ShockIncrements.Value);
返回视图(@“~\Views\Indications\TermSheetViews\Swap\PrePayment.aspx”,结果列表);
  • 这可以编译,但是,我可以这样做吗
  • 我需要用javascript处理这个列表,我在另一个页面上有代码,可以从AJAX获取Json格式的列表,但在这种情况下,我没有能力这样做。然后,我将如何使用以下方法处理通过javascript传递的列表:

    CreateShockTable(data.preadmentList,“TotalValueString”,“#valueTable”,“预付款值”)

  • 那个
    预付款列表就是这个列表

  • 是的,你可以

    var myList=ViewData[“任意”]作为列表

  • 它在序列化过程中被转换为JSON数组,因此您可以轻松地循环使用它。 我不太明白“通过javascript传递”是什么意思。这是通过Ajax调用的操作的结果吗


  • 您可以使用以下命令将模型序列化为JSON对象:

    
    var预付款清单=;
    //TODO:使用此处的列表,例如,将其传递给某个函数:
    CreateShockTable(
    预付款清单,
    “TotalValueString”,
    “#valueTable”,
    “预付款价值”
    );
    
    我目前正在尝试将其声明为ViewData,然后将其传回。我会让你们知道它是如何运作的。不过我该如何访问它呢?
    <script type="text/javascript">
        var prepaymentList = <%= new JavaScriptSerializer().Serialize(Model) %>;
        // TODO: use the list here, for example pass it to some function:
        CreateShockTable(
            prepaymentList, 
            "TotalValueString", 
            "#valueTable", 
            "Prepayment Value"
        );
    </script>