private void GetCommentList(HttpContext CurrentContext) { CommentBll bll = new CommentBll(); int NewsID = Convert.ToInt32(CurrentContext.Request["nid"]); if (NewsID == 0) { CurrentContext.Response.Write(GetJsonResult(false, "参数错误!")); return; } DataTable dt = bll.GetList(AppType.News, NewsID); StringBuilder result = new StringBuilder(); StringWriter sw = new StringWriter(result); JsonWriter writer = new JsonWriter(sw); writer.Formatting = Formatting.Indented; writer.WriteStartArray(); foreach (DataRow row in dt.Rows) { writer.WriteStartObject(); WriteJsonKeyValue(writer, "userid", row["userid"].ToString()); WriteJsonKeyValue(writer, "content", row["content"].ToString()); WriteJsonKeyValue(writer, "createtime", Convert.ToDateTime(row["createtime"]).ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteEndObject(); } writer.WriteEndArray(); writer.Close(); CurrentContext.Response.Write("(" + result.ToString() + ")"); }
public DataTable GetNewsComments(int NewsID) { CommentBll bll = new CommentBll(); return bll.GetList(AppType.News, NewsID); }