private void BindTags() { this.Title = "Tags列表"; EyouSoft.BLL.NewsStructure.TagKeyInfo TagKeyInfoBll = new EyouSoft.BLL.NewsStructure.TagKeyInfo(); IList <EyouSoft.Model.NewsStructure.TagKeyInfo> list = TagKeyInfoBll.GetAllTag(); if (list != null && list.Count > 0) { int i = 1; foreach (var item in list) { html += string.Format("<a class=\"tagc{0}\" href=\"{1}\">{2}</a>", i++ % 2 == 0 ? 1 : 2, EyouSoft.Common.URLREWRITE.Infomation.GetOtherListUrl(item.Id), item.ItemName); } } }
public void Databind() { //要显示关键字(1),还是Tag(2) string keyOrTags = EyouSoft.Common.Utils.GetQueryStringValue("keyOrTags"); //关键字Tag标题 string keyOrTagsTitle = EyouSoft.Common.Utils.GetQueryStringValue("keyOrTagsTitle"); //是否要异步请求数据 bool isAjax = Convert.ToBoolean(EyouSoft.Common.Utils.GetQueryStringValue("isAjax")); EyouSoft.BLL.NewsStructure.TagKeyInfo tagKeyInfoBLL = new EyouSoft.BLL.NewsStructure.TagKeyInfo(); IList <EyouSoft.Model.NewsStructure.TagKeyInfo> list = new List <EyouSoft.Model.NewsStructure.TagKeyInfo>(); System.Text.StringBuilder str = new System.Text.StringBuilder(); //是关键字 if (keyOrTags == "1") { if (!string.IsNullOrEmpty(keyOrTagsTitle)) { list = tagKeyInfoBLL.GetAllKeyWord(keyOrTagsTitle); } else { list = tagKeyInfoBLL.GetAllKeyWord(); } } //Tag else if (keyOrTags == "2") { if (!string.IsNullOrEmpty(keyOrTagsTitle)) { list = tagKeyInfoBLL.GetAllTag(keyOrTagsTitle); } else { list = tagKeyInfoBLL.GetAllTag(); } } if (list != null) { for (int i = 0; i < list.Count; i++) { //每行显示8列,奇数列显示颜色:white,偶数列显示颜色:#f3f7ff if (i % 8 == 0) { str.AppendFormat("<tr bgcolor=\"{0}\">", ((i / 8)) % 2 == 0 ? "#f3f7ff" : "white"); } str.AppendFormat("<td><input id=\"{0}\" name=\"selKey\" type=\"checkbox\" /><label for=\"{0}\">{1}</label></td>", list[i].Id, list[i].ItemName); if (i + 1 % 10 == 0 && i > 0) { str.Append("</tr>"); } } } //是否异步请求 if (isAjax) { Response.Clear(); Response.Write(str); Response.End(); } list = null; tagKeyInfoBLL = null; Html = str.ToString(); }