Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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>
     }
 }
Posted

1 solution

change:
C#
 @j=@j+6;
@y=@y+6;

to
C#
 @{
j=j+6;
y=y+6;}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900