Example #1
0
 public void RptBind()
 {
     string strWhere = "";
     string strUid = "";
     try
     {
         strUid = this.Session["hyuid"].ToString();
     }
     catch
     {
     }
     if (strUid != "")
     {
         strWhere = " and hy_uid='" + strUid + "' ";
     }
     else
     {
         return;
     }
     JpFavorite jpFavorite = new JpFavorite();
     DataTable dt = jpFavorite.GetData(strWhere);
     StringBuilder stringBuilder = new StringBuilder();
     int commentCount = 0;
     JpComment jpComment = new JpComment();
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         DataTable dtComment = jpComment.Getdocsbyaid_ysh(pis_cid, dt.Rows[i]["hy_aid"].ToString());
         commentCount = dtComment.Rows.Count;
         stringBuilder.Append("<li><a onclick=\"locationDetail('art_detail.aspx?aid=" + dt.Rows[i]["hy_aid"].ToString() + "&cid=" + dt.Rows[i]["hy_cid"].ToString() + "','" + locationType + "','1')\">" + dt.Rows[i]["hy_bt"].ToString() + "</a>");
         stringBuilder.Append("<span>" + dt.Rows[i]["hy_addtime"].ToString() + "</span>");
         stringBuilder.Append("</li>");
     }
     this.lb_show.Text = stringBuilder.ToString();
 }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string ls_cid = "", ls_page = "1", la_pagesize = "10";
        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        if (this.Request.QueryString["cid"] != null)
        {
            ls_cid = JpCommon.queryString2StrID(this.Request.QueryString["cid"].ToString(), 9);
        }
        if (this.Request.QueryString["page"] != null)
        {
            ls_page = JpCommon.Filter(this.Request.QueryString["page"].ToString());
        }
        if (this.Request.QueryString["pagesize"] != null)
        {
            la_pagesize = JpCommon.Filter(this.Request.QueryString["pagesize"].ToString());
        }
        //根据传入的文章栏目ID、页码、页数返回列表信息
        TPortalClass.JpArticle JpArticle = new TPortalClass.JpArticle();
        string ls_where = "", ls_order = "";
        ls_where = " and cid like '" + ls_cid + "%' and sfzwd='否' ";
        ls_order = " order by pubtime desc";
        DataTable dt = JpArticle.SearchdocsByKey(ls_where, ls_order, int.Parse(ls_page), int.Parse(la_pagesize));
        //复制一个DataTalbe
        DataTable tempTable = dt.Clone();
        //在现有的DatatTable增加一列
        DataColumn col = new DataColumn("showTime", typeof(String));
        //将列添加到DataTable中去
        tempTable.Columns.Add(col);

        //在现有的DatatTable增加一列
        DataColumn col2 = new DataColumn("commentCount", typeof(String));
        //将列添加到DataTable中去
        tempTable.Columns.Add(col2);

        int commentCount = 0;
        JpComment jpComment = new JpComment();
        //循环  对DataTable重新赋值
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow dr = tempTable.NewRow();
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                dr[tempTable.Columns[j].ColumnName] = dt.Rows[i][j];
            }
            DataTable dtComment = jpComment.Getdocsbyaid_ysh(ls_cid, dt.Rows[i]["aid"].ToString());
            commentCount = dtComment.Rows.Count;
            //获得间隔的时间
            dr["showTime"] = JpCommon.DateDiff(DateTime.Now, Convert.ToDateTime(dt.Rows[i]["crtime"].ToString()));
            dr["commentCount"] = commentCount;
            tempTable.Rows.Add(dr);
        }
        //转换成json格式
        string strJson = JsonConvert.SerializeObject(tempTable);
        //数据抛出
        Response.Write(strJson);
    }