private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.article_spec bll = new BLL.article_spec(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("spec_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//嵌套绑定 protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e) { BLL.article_spec bll = new BLL.article_spec(); if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Repeater rptSpecItem = (Repeater)e.Item.FindControl("rptSpecItem"); //找到关联的数据项 DataRowView drv = (DataRowView)e.Item.DataItem; //提取父ID int parentId = Convert.ToInt32(drv["id"]); //根据父ID查询并绑定 rptSpecItem.DataSource = bll.GetList(0, "parent_id=" + parentId, "sort_id asc,id desc"); rptSpecItem.DataBind(); } }
private void RptBind(string _strWhere, string _orderby) { BLL.article_spec bll = new BLL.article_spec(); this.rptList.DataSource = bll.GetList(0, _strWhere, _orderby); this.rptList.DataBind(); }