mvc ViewData["existProductDic"] 数据字典 便利

 

控制器:

var existProductDic = new Dictionary<string, bool>();
foreach (var item in merSingleList)
{
int a = BLL.existespecialShop(item.ProID, item.Sku_ID, vo.Fid);
existProductDic.Add(string.Format("{0}-{1}", item.ProID, item.Sku_ID), a > 0);

}
ViewData["existProductDic"] = existProductDic;

 

 

<%
var productStatusDic = ViewData["existProductDic"] as Dictionary<string, bool>;
%>

 

view

<%
if (productStatusDic != null)
{
var isExist = productStatusDic[string.Format("{0}-{1}", item.ProID, item.Sku_ID)];
if (isExist)
{ %>
<input type="button" class="btns" value="已加入" />
<input type="button" class="btns" value="撤销" onclick="Revoke('<%:item.ProID %>','<%:item.Sku_ID %>')" />

<% }
else
{ %>
<input type="button" class="btns" value="加入商品" onclick="validateShop('<%:i %>')" />
<% }

}%>

posted @ 2016-01-20 19:30  昙花千尺  阅读(196)  评论(0编辑  收藏  举报