mvc2.0与3.0 便利一行三个元素 便利多行代码

2.0
<% List<GomeCps.Entity.EntityVO.EarnerInfosVO> list = ViewData["list"] as List<GomeCps.Entity.EntityVO.EarnerInfosVO>; %>

<% if(list != null && list.Count > 0) {%>
<% for (int i=0 ;i<list.Count ;i++)
{%>
<% if(i==0)
{%>
<tr>
<%} %>

<% if(i >0&&i% 2==0)
{%>
</tr>
<tr>
<%} %>
<td width="5%" style=" 20px"><%: list[i].Ea%></td>
<td width="10%"><input type="text" readonly="readonly" style="border: none; 43px" name="Ear" value="<%:list[i].Com %>"/></td>
<td width="10%"><span><%:list[i].SumPrice %></span></td>
<td ><input type="checkbox" id="items" name="items" value="<%: list[i].Ear %>"/></td>

<% if( i==list.Count-1)
{%>
</tr>
<%} %>

<% } %>
<% } %>

3.0


@{

const int step = 4;
for (int i = 0; i < Model.Count;)
{
int mid1 = i + step;
int midLen = mid1 > Model.Count ? Model.Count : mid1;
<ul class="shop_hot-list clearfix" style="float:left;">
@for (int j = i; j < midLen; j++)
{
<li>
<div class="hot-listcon">
<a href="@(Model[j].WapUrl)?openid=@openId">
<img src="@Model[j].ImageUrl" alt=""/>
<p class="fc6 fs12 ellipsis_two" style="height:3.2rem;">@WebHelper.SubString(Model[j].Description, 20)</p>
<div class="clearfix">

<p style="color: #ef3030; margin-top:5px;">¥<span>@WebHelper.MoneyStr(@Model[j].Price)</span></p>

@if(isShowCommission)
{
<p class="mt4 border_red" >红¥<span>@WebHelper.MoneyStr(@Model[j].Commission)</span></p>
}


</div>
</a>
</div>

</li>
}

</ul>
i += step;

}
}

List<StoreProductCategorycount> Categorylist = ViewBag.CategoryList as List<StoreProductCategorycount>;

原文地址:https://www.cnblogs.com/fu123/p/5139664.html