怎对于Foreach 不能添加IF的问题
2024-09-07 23:55:45
我不们直接在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="width: 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="width: 80px; margin-right: 5px; margin: 5px;">
@item.CZMC
</a>
}
这样就可以正常运行。
最新文章
- owner:轻松管理java项目配置
- 必杀技———SQL基础整理系列(一)
- ubuntu下安装lrzsz
- BZOJ 2463: [中山市选2009]谁能赢呢?
- 基于WWF搭建的通用审批流程
- [C]遍历目录下所有文件
- Linux QT
- 9-cat 简明笔记
- Storm-166:Nimbus HA solution based on Zookeeper
- js 字符串转 数字
- 在JavaScript 自定义对象来模拟Java中的Map
- get mac 20150202
- LSI SAS 2308配置操作
- POJ1363:Rails
- Warning: Cannot modify header information - headers already sent by (output started at
- Openjudge-计算概论(A)-简单算术表达式求值
- 【转】vue父子组件之间的通信
- nodejs koa2 框架中,mongoose update一条数据
- 2、JDBC-CURD
- Java学习——上转型与下转型对象