counter
counter

小问题

1.前台页面,根据后台函数取值

<asp:TemplateField>
<HeaderTemplate>
所属学校</HeaderTemplate>
<ItemTemplate>
<%#GetSchoolName(Convert.ToInt32(Eval("SchoolId").ToString()))%>
</ItemTemplate>
<ItemStyle CssClass="x-grid4-row" HorizontalAlign="center" />
<HeaderStyle CssClass="x-grid4-hd-cell" HorizontalAlign="Center" />
</asp:TemplateField>

SchoolId是绑定数据源中含有的字段

2.

//生成添加入缓存的 Key。
var key = string.Format(CacheKeys.LIST_CITY, cityId);  // public static readonly string LIST_CITY = "/Gui/Category/City/{0}";
//根据 Key 获取缓存数据。
CategoryList = Cache.Get<List<CategoryInfo>>(key);   // T Get<T>(string key) where T : class;  Nosql

//如果缓存数据不存在,从数据库重新获取。
if (CategoryList == null ||CategoryList.Count == 0)
{
//从数据库获取获取指定城市的所有有效学校产品类目信息。
CategoryList = GetCategoryByCity(cityId);

//如果从数据库获取的数据不为空,添加到缓存。
if (CategoryList != null && CategoryList.Count > 0)
{
//将数据添加入缓存 30 分钟。
Cache.Add(key, CategoryList, CacheExpires.ONE_DAY);
}
}

posted @ 2012-05-30 17:52  bfy  阅读(164)  评论(0编辑  收藏  举报