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); }
private void RptBind() { if (this.Request.QueryString["page"] != null) this.page = int.Parse(this.Request.QueryString["page"].ToString()); else this.page = 1; this.txtKeywords.Text = this.keywords; txtPageNum.Text = this.pageSize.ToString(); txtPage.Text = this.page.ToString(); TPortalClass.JpHelp JpHelp = new TPortalClass.JpHelp(); TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon(); string ls_key = JpCommon.Filter(this.txtKeywords.Text.Trim()); DataTable dt = new DataTable(); string ls_where = " and hy_content like '%" + ls_key + "%' "; dt = JpHelp.SearchdocsByKey(ls_where, " order by hy_ifsh ", Convert.ToInt32(txtPage.Text), 10); this.totalCount = JpHelp.SearchdocsByKeyNum(ls_where); rptList.DataSource = dt; rptList.DataBind(); string pageUrl = JpCommon.CombUrlTxt("list_help_sh.aspx", "page={0}&rnd={1}&keywords={2}", "__id__", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtKeywords.Text + ""); PageContent.InnerHtml = JpCommon.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind() { if (this.Request.QueryString["page"] != null) this.page = int.Parse(this.Request.QueryString["page"].ToString()); else this.page = 1; this.txtKeywords.Text = this.keywords; txtPageNum.Text = this.pageSize.ToString(); txtPage.Text = this.page.ToString(); TPortalClass.JpActivityusers JpActivityusers = new TPortalClass.JpActivityusers(); TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon(); string ls_key = JpCommon.Filter(this.txtKeywords.Text.Trim()); DataTable dt = new DataTable(); string sql = ""; sql = " Select top 10 a.hy_bt,b.hy_name,b.hy_tel,b.hy_addtime,b.hy_ifsh,b.hy_id,b.id from hy_activity a,hy_activityusers b "; sql += " where 1=1 and b.hy_id=a.id and a.hy_bt like '%" + ls_key + "%' and a.id not in(select top 0 a.id "; sql += " from hy_activity a,hy_activityusers b where 1=1 and hy_bt like '%" + ls_key + "%' order by a.hy_sort desc,b.hy_sort desc ) "; sql += " order by a.hy_sort desc,b.hy_sort desc"; TPortalClass.DAO db = new TPortalClass.DAO(); dt = db.GetDataTable(sql); string sql_count = "Select count(*) as num from hy_activity a,hy_activityusers b"; sql_count += " where 1=1 and b.hy_id=a.id and a.hy_bt like '%" + ls_key + "%' "; DataTable dt_count = db.GetDataTable(sql_count); if (dt_count.Rows.Count > 0) { this.totalCount = Convert.ToInt32(dt_count.Rows[0]["num"].ToString()); } else { this.totalCount = 0; } rptList.DataSource = dt; rptList.DataBind(); string pageUrl = JpCommon.CombUrlTxt("list_activityusers.aspx", "page={0}&rnd={1}&keywords={2}", "__id__", "" + System.Guid.NewGuid().ToString() + "", "" + this.txtKeywords.Text + ""); PageContent.InnerHtml = JpCommon.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }