private void BindRelateArticles() { StringBuilder sb = new StringBuilder(); DataTable table = new DataTable(); string where = "isdisplay = 1"; if (news.IsSanxia) { table = newsBll.GetData(10, where + " and IsSanxia = 1", "ID desc "); } else { string where2 = " and CHARINDEX('," + routeClassId + ",',','+routeClassID+',') > 0 "; table = newsBll.GetData(10, where + where2, "ID desc "); if (table.Rows.Count < 10) { ClassLibrary.Model.RouteClass crc = gList.Find(delegate(ClassLibrary.Model.RouteClass rc) { return(rc.ID == routeClassId); }); if (crc.ClassLevel == 4) { DataTable table4 = newsBll.GetData(10, where + " and CHARINDEX('," + crc.ParentID + ",',','+routeClassID+',') > 0 ", "ID desc"); table.Merge(table4); table = table.AsDataView().ToTable(true); } } } if (table.Rows.Count < 10) { DataSet mySet2 = newsBll.GetPageData(10, 1, where, "ID desc "); DataTable table2 = mySet2.Tables["Data"]; table.Merge(table2); table = table.AsDataView().ToTable(true); } int i = 0; List <ClassLibrary.Model.News> raList = newsBll.GetModelList(table); foreach (ClassLibrary.Model.News model in raList) { i++; string preurl = Enum.GetName(typeof(SysConfig.NewsClassPY), model.newsClassID); sb.AppendFormat("<li><a href='{0}/{1}/{2}.html' title='{3}' target='_blank'>{4}</a><span>{5}</span></li>", SysConfig.webSite, preurl, model.ID, model.Title, Function.Clip(model.Title, 20, false), model.CreatedTime.ToString("yyyy-MM-dd")).AppendLine(); if (i >= 10) { break; } } relateArticleList = sb.ToString(); }
private void BindData() { DataTable myTable = newsBLL.GetData(" id =" + newsId); if (myTable.Rows.Count == 1) { newsClassId = Convert.ToInt32(myTable.Rows[0]["newsClassID"]); routeClassId = myTable.Rows[0]["routeClassID"].ToString(); if (routeClassId != "") { routeParentId = Convert.ToInt32(routeClassId.Split(',')[0]); } title = myTable.Rows[0]["Title"].ToString(); editor = myTable.Rows[0]["Editor"].ToString(); source = myTable.Rows[0]["Source"].ToString(); image = myTable.Rows[0]["Image"].ToString(); content = myTable.Rows[0]["Content"].ToString(); seoKeywords = Convert.ToString(myTable.Rows[0]["seoKeyword"]); seoDescription = Convert.ToString(myTable.Rows[0]["seoDescription"]); isdisplay = Convert.ToBoolean(myTable.Rows[0]["isDisplay"]); issanxia = Convert.ToBoolean(myTable.Rows[0]["IsSanxia"]); ntag = myTable.Rows[0]["ntag"].ToString(); } else { Function.goMessagePage("修改文章", "操作失败,数据不存在!", "News/NewsList.aspx?cid=" + newsClassIDs); } }