zoukankan      html  css  js  c++  java
  • 怎对于Foreach 不能添加IF的问题

    我不们直接在Foreach 里面直接添加IF,这样会报错,这个前提是子视图,其他的我没有试验过。像这样:

    @foreach (Gift.Modules.Model.Entitys.XT_CZ item in ViewData["ZTCZ"] as IList<Gift.Modules.Model.Entitys.XT_CZ>)
    {
        string htmlfaction = @item.Action + "()";
        if (true)
        {
             @saveorcancel = true;
        }
        <a href="javascript:void(0)" id="@item.Action" onclick="@htmlfaction" class="easyui-linkbutton" data-options="iconCls:'@item.IconCls'" style=" 80px; margin-right: 5px; margin: 5px;">
            @item.CZMC
        </a>
    }
    

     应该改成这样:

    @foreach (Gift.Modules.Model.Entitys.XT_CZ item in ViewData["ZTCZ"] as IList<Gift.Modules.Model.Entitys.XT_CZ>)
    {
        string htmlfaction = @item.Action + "()";
        <text>
        @if (true)
        {
             saveorcancel = true;
        }
        </text>
        <a href="javascript:void(0)" id="@item.Action" onclick="@htmlfaction" class="easyui-linkbutton" data-options="iconCls:'@item.IconCls'" style=" 80px; margin-right: 5px; margin: 5px;">
            @item.CZMC
        </a>
    }
    

     这样就可以正常运行。

  • 相关阅读:
    CodeForces 404C Ivan and Powers of Two
    CodeForces 433C Ryouko's Memory Note-暴力
    if not
    python3的print函数
    交叉熵
    tensorflow一个很好的博客
    关于第几维的问题
    更新软件
    tensorflow训练代码
    tensorflow的一些函数
  • 原文地址:https://www.cnblogs.com/armyant/p/3761631.html
Copyright © 2011-2022 走看看