不能在MVC视图中使用加法赋值运算符 [英] can't use addition assignment operator in MVC view
本文介绍了不能在MVC视图中使用加法赋值运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
i无法在MVC视图中执行添加分配操作。
在此我无法做到@ j = @ j + 6;
我的代码如下:
Hi Friends,
i cann't do addition assignment operation in MVC view.
in this i can't do @j=@j+6;
my code is below:
@model Tishansoft.Model.Block
@{
var BlockList = ViewBag.BLockList as IEnumerable<Tishansoft.Model.Block>;
var six_blocks=BlockList.Where(x=>x.BlockTypeId==3);
Decimal count=six_blocks.Count();
int list=Convert.ToInt16(Math.Ceiling(count/6));
int j = 6;
int y = 1;
}
@foreach (var blocktype in BlockList.Where(x => x.BlockId != null))
{
if (blocktype.BlockTypeId == 3)
{
<div class="recent-work clearfix bottom-2">
<div class="slidewrap1" >
<div class="sixteen columns">
<h3 class="title bottom-2">Recent Work</h3>
</div>
<ul class="slider" id="sliderName1">
@for (int i = 0; i < list; i++)
{
<li class="slide">
@foreach (var item in six_blocks.Where(x => x.BlockId <= j&&x.BlockId>=y))
{
<!-- item -->
<div class="one-third column item">
<a href="@item.BlockURL.ToString()">
<img src="../Content/images/portfolio/@item.BlockImage.ToString()" alt="" class="pic" />
<div class="img-caption">
<div class="desc"><h3>@item.BlockTitle</h3><p>@item.BlockContent</p><span>+</span></div>
</div><!-- hover effect -->
</a>
</div>
<!-- End -->
}
@j=@j+6;
@y=@y+6;
</li>
}
</ul>
</div>
</div>
}
}
推荐答案
更改:
change:
@j=@j+6;
@y=@y+6;
to
to
@{
j=j+6;
y=y+6;}
这篇关于不能在MVC视图中使用加法赋值运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文