public void dlBind() { int curpage = Convert.ToInt32(labNowPage.Text); PagedDataSource ps = new PagedDataSource(); string strSql = "SELECT * FROM tb_LeaveWord order by DateTime Desc"; SqlCommand myCmd = dbObj.GetCommandStr(strSql); DataTable dsTable = dbObj.GetDataSet(myCmd, "tbLeaveWord"); ps.DataSource = dsTable.DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 10; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 lnkbtnPrve.Enabled = true; lnkbtnTop.Enabled = true; lnkbtnNext.Enabled = true; lnkbtnLast.Enabled = true; if (curpage == 1) { lnkbtnTop.Enabled = false;//不显示第一页按钮 lnkbtnPrve.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { lnkbtnNext.Enabled = false;//不显示下一页 lnkbtnLast.Enabled = false;//不显示最后一页 } this.labCount.Text = Convert.ToString(ps.PageCount); this.dlManage.DataSource = ps; this.dlManage.DataKeyField = "ID"; this.dlManage.DataBind(); }
/// <summary> /// DataList控件绑定及分页 /// </summary> /// <param name="intCount">每页显示的记录条数</param> /// <param name="ds">DataSet数据集</param> /// <param name="labPage">当前页码</param> /// <param name="labTPage">总页码</param> /// <param name="lbtnUp">上一页</param> /// <param name="lbtnNext">下一页</param> /// <param name="lbtnBack">最后一页</param> /// <param name="lbtnOne">第一页</param> /// <param name="dl">DataList控件对象</param> public static void dlBind(int intCount, DataSet ds, Label labPage, Label labTPage, LinkButton lbtnUp, LinkButton lbtnNext, LinkButton lbtnBack, LinkButton lbtnOne, Repeater dl) { int curpage = Convert.ToInt32(labPage.Text); PagedDataSource ps = new PagedDataSource(); ps.DataSource = ds.Tables[0].DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = intCount; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 lbtnNext.Visible = true; lbtnOne.Visible = true; lbtnBack.Visible = true; lbtnUp.Visible = true; lbtnNext.Enabled = true; lbtnBack.Enabled = true; lbtnOne.Enabled = true; if (curpage == 1) { lbtnOne.Visible = false;//不显示第一页按钮 lbtnUp.Visible = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { lbtnNext.Visible = false;//不显示下一页 lbtnBack.Visible = false;//不显示最后一页 } labTPage.Text = Convert.ToString(ps.PageCount); dl.DataSource = ps; // dl.DataKeyField = "ID"; dl.DataBind(); }
protected void BindList() { // edit by shiney string type = ViewState["type"].ToString(); DataTable dt = AccessHelper.ExecuteDataTable(strConnection, CommandType.Text, "select C.ID,C.Title,C.CreateTime,C.ViewTimes,T.TypeCode from Contents C,ContentAndType CT,ContentType T where C.ID=CT.ContentID And T.ID=CT.TypeID And T.TypeCode='" + type + "'"); // "SELECT ID, Title, CreateTime,ViewTimes FROM Contents WHERE TypeCode = '" + type + "'"); if (dt == null) return; if (dt.Rows.Count == 0) { dvEmpty.InnerHtml += "此栏目暂无信息"; dvbtn.Visible = false; } if (dt.Rows.Count > 0) dvbtn.Visible = true; PagedDataSource ps = new PagedDataSource(); ps.AllowPaging = true; ps.PageSize = 16; rpList.DataSource = ps; ps.CurrentPageIndex = Convert.ToInt32(this.lbCurPage.Text) - 1; ps.DataSource = dt.DefaultView; this.btnPreviousPage.Enabled = true; this.btnNextPage.Enabled = true; if (ps.CurrentPageIndex == 0) { this.btnPreviousPage.Enabled = false; } if (ps.CurrentPageIndex == ps.PageCount - 1) { this.btnNextPage.Enabled = false; } rpList.DataBind(); }
//绑定搜索的课程信息 public void DataBindSearchCourse() { DalOperationAboutGradeCheck dal = new DalOperationAboutGradeCheck(); // Response.Write(ddlCourses.SelectedValue); DataTable dt = dal.GetAllStudentGradeCheckApply(ddlCourses.SelectedValue == "all" ? "all_" + ddlTermTags.SelectedValue : ddlCourses.SelectedValue, ddlApplyResult.SelectedValue, ddlApplyLocale.SelectedValue).Tables[0]; DataView dv = dt.DefaultView; this.AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = CommonUtility.pageSize; this.dlstGradeCheckApply.DataSource = pds; this.dlstGradeCheckApply.DataBind(); if (dt.Rows.Count == 0) { this.dlstGradeCheckApply.ShowFooter = true; } else { this.dlstGradeCheckApply.ShowFooter = false; } }
protected void bindNew() { //获取当前页码 int noncePage = Convert.ToInt32(labPage.Text); //创建PagedDataSource对象用来实现分页 PagedDataSource ps = new PagedDataSource(); string sqlSel = "select * from videoInfo where Auditing='1' order by videoDate desc"; //调用公共类中的getRows方法并将所返回的所有数据绑定到PagedDataSource数据源中 ps.DataSource = operateData.getRows(sqlSel).DefaultView; //设置启动分页 ps.AllowPaging = true; //设置每页显示的项数 ps.PageSize = 8; //设置当前页的索引 ps.CurrentPageIndex = noncePage - 1; this.lnkbtnFront.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnLast.Enabled = true; this.lnkbtnFirst.Enabled = true; //如果当前为第一页将不显示第一页按钮和上一页按钮 if (noncePage == 1) { this.lnkbtnFirst.Enabled = false;//不显示第一页按钮 this.lnkbtnFront.Enabled = false;//不显示上一页按钮 } //如果当前为最后一页将不显示最后一页按钮和下一页按钮 if (noncePage == ps.PageCount) { this.lnkbtnNext.Enabled = false;//不显示下一页 this.lnkbtnLast.Enabled = false;//不显示最后一页 } labBackPage.Text = Convert.ToString(ps.PageCount); dlNewVideo.DataSource = ps; dlNewVideo.DataBind(); }
public void FilterSearch() { if (Session["kindid"] != null && Session["name"] != null) { PagedDataSource objPage = new PagedDataSource(); try { DataSet ds = new DataSet(); ds = getDS.getData("Product"); DataTable dt = new DataTable(); dt = ds.Tables[0]; DataView dv = new DataView(dt); dv.RowFilter = "KindID = '" + Session["kindid"].ToString() + "' and ProName = '" + Session["name"].ToString() + "'"; DataList1.RepeatColumns = 3; DataList1.DataSource = dv; DataList1.DataBind(); } catch (Exception ex) { } finally { objPage = null; } } else { } }
private void BindRepeater() { this.cmd.CommandText = "SELECT ForumMessages.Body, ForumMessages.CreationDate, ForumTopics.TopicID, ForumTopics.Subject " + "FROM ForumMessages INNER JOIN ForumTopics ON ForumMessages.TopicID=ForumTopics.TopicID " + "WHERE ForumTopics.ForumID NOT IN (SELECT DISTINCT ForumID FROM ForumGroupPermissions) " + "AND ForumMessages.UserID='" + userID + "' ORDER BY ForumMessages.CreationDate"; DbDataAdapter da = providerFactory.CreateDataAdapter(); da.SelectCommand = this.cmd; DataTable dt = new DataTable(); da.Fill(dt); PagedDataSource pagedSrc = new PagedDataSource(); pagedSrc.DataSource = dt.DefaultView; pagedSrc.AllowPaging = true; pagedSrc.PageSize = this.pageSize; int curPage = 0; if(Request.QueryString["page"]!=null) int.TryParse(Request.QueryString["page"], out curPage); pagedSrc.CurrentPageIndex = curPage; //prepare a string for the "pager" at the bottom pagerString = ""; for (int i = 0; i < pagedSrc.PageCount; i++) { if (i == curPage) pagerString += " " + (i + 1); else pagerString += " <a href=viewpostsbyuser.aspx?UserID=" + userID + "&Page=" + i + ">" + (i + 1) + "</a>"; } this.rptMessagesList.DataSource = pagedSrc; this.rptMessagesList.DataBind(); }
public void dlBind() { int curpage = Convert.ToInt32(labNowPage.Text); PagedDataSource ps = new PagedDataSource(); string sqlStr = "SELECT * FROM tb_Reply WHERE ReplyID='" + Request["ID"].ToString() + "'"; SqlCommand myCmd=dbObj.GetCommandStr(sqlStr); DataTable dsTable = dbObj.GetDataSet(myCmd, "tbReplay"); ps.DataSource = dsTable.DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 10; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 lnkbtnPrve.Enabled = true; lnkbtnTop.Enabled = true; lnkbtnNext.Enabled = true; lnkbtnLast.Enabled = true; if (curpage == 1) { lnkbtnTop.Enabled = false;//不显示第一页按钮 lnkbtnPrve.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { lnkbtnNext.Enabled = false;//不显示下一页 lnkbtnLast.Enabled = false;//不显示最后一页 } this.labCount.Text = Convert.ToString(ps.PageCount); this.DataList1.DataSource = ps; this.DataList1.DataKeyField = "ID"; this.DataList1.DataBind(); }
//绑定文章信息 public void DataListBindAdminNotify(int type) { DalOperationAboutAdminNotify doan = new DalOperationAboutAdminNotify(); DataView dv = null; if(type==0) dv = doan.GetAllNotifys().Tables[0].DefaultView; else dv=doan.FindNotifyByTypeId(type).Tables[0].DefaultView; this.AspNetPager1.RecordCount = dv.Count; AspNetPager1.PageSize = CommonUtility.pageSize; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = AspNetPager1.PageSize; this.dlNotify.DataSource = pds; this.dlNotify.DataBind(); if (pds.Count > 0) { this.dlNotify.ShowFooter = false; } }
public void dlImageBind() { string strSql = "select * from tb_Image"; DataTable dsTable = dbObj.GetDataSetStr(strSql, "tbImage"); int curpage = Convert.ToInt32(this.labPage.Text); PagedDataSource ps = new PagedDataSource(); ps.DataSource = dsTable.DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 16; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 this.lnkbtnUp.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnBack.Enabled = true; this.lnkbtnOne.Enabled = true; if (curpage == 1) { this.lnkbtnOne.Enabled = false;//不显示第一页按钮 this.lnkbtnUp.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { this.lnkbtnNext.Enabled = false;//不显示下一页 this.lnkbtnBack.Enabled = false;//不显示最后一页 } this.labBackPage.Text = Convert.ToString(ps.PageCount); this.dlImage.DataSource = ps; this.dlImage.DataKeyField = dsTable.Columns[0].ToString(); this.dlImage.DataBind(); }
protected void bindDlUserHaving() { int noncePage = Convert.ToInt32(labPage.Text); PagedDataSource ps = new PagedDataSource(); string sqlSel = "select * from userInfo order by id desc"; ps.DataSource = operateData.getRows(sqlSel).DefaultView; ps.AllowPaging = true; ps.PageSize = 9; ps.CurrentPageIndex = noncePage - 1; this.lnkbtnFront.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnLast.Enabled = true; this.lnkbtnFirst.Enabled = true; if (noncePage == 1) { this.lnkbtnFirst.Enabled = false;//不显示第一页按钮 this.lnkbtnFront.Enabled = false;//不显示上一页按钮 } if (noncePage == ps.PageCount) { this.lnkbtnNext.Enabled = false;//不显示下一页 this.lnkbtnLast.Enabled = false;//不显示最后一页 } labBackPage.Text = Convert.ToString(ps.PageCount); dlUserHaving.DataSource = ps; dlUserHaving.DataBind(); }
protected void DataListBindCourseNotify() { DalOperationAboutCourses doac = new DalOperationAboutCourses(); DataView dv = doac.GetCoursesInfo(Master.courseNo,Master.classID,Master.termtag, "3").Tables[0].DefaultView;//第3个标签,绑定课程通知信息 this.AspNetPager2.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = CommonUtility.pageSize; ; this.dlstCourseNotify.DataSource = pds; this.dlstCourseNotify.DataBind(); if (this.dlstCourseNotify.Items.Count == 0) { btnDelete.Visible = false; } else { btnDelete.Visible = true; } if (pds.Count > 0) { this.dlstCourseNotify.ShowFooter = false; } }
//绑定main文章 public void GWbind() { int curpage = Convert.ToInt32(this.labPage.Text); PagedDataSource ps = new PagedDataSource(); //conn.Open(); string sql = "select * from tb_PostMsg order by ID DESC"; SqlDataAdapter da = new SqlDataAdapter(sql, conn); da.Fill(ds, "tb_PostMsg"); ps.DataSource = ds.Tables["tb_PostMsg"].DefaultView; //ps.DataSource = sh.GetDataSet(sql, "PostMsg"); ps.AllowPaging = true; //是否可以分页 ps.PageSize = 15; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 this.lnkbtnUp.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnBack.Enabled = true; this.lnkbtnOne.Enabled = true; if (curpage == 1) { this.lnkbtnOne.Enabled = false;//不显示第一页按钮 this.lnkbtnUp.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { this.lnkbtnNext.Enabled = false;//不显示下一页 this.lnkbtnBack.Enabled = false;//不显示最后一页 } this.labBackPage.Text = Convert.ToString(ps.PageCount); this.GridView1.DataSource = ps; this.GridView1.DataBind(); //conn.Close(); }
public void grdbind() { using (Entities bll = new Entities()) { IEnumerable<L_RForm> lfeed; if (!string.IsNullOrEmpty(Request.Params["ID"])) { _Id = int.Parse(HttpContext.Current.Request.QueryString["ID"]); lfeed = bll.L_RForm.Where(p => p.FID == _Id).OrderByDescending(p => p.FID).Select(c => c); } else { lfeed = bll.L_RForm.OrderByDescending(p => p.FID).Select(c => c); } PagedDataSource pds = new PagedDataSource(); pds.DataSource = lfeed.ToList(); //这里好像一定要Tolist();不然会有点错误; pds.AllowPaging = true; AspNetPager1.RecordCount = lfeed.Count(); //记录总数; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; this.rptList.DataSource = pds; this.rptList.DataBind(); } }
EP ep = new EP(); //实例化一个对象 #endregion Fields #region Methods public void bindDataList() { int curpage = Convert.ToInt32(this.labPage.Text); PagedDataSource ps = new PagedDataSource(); SqlConnection con = new SqlConnection(EP.GetConStr()); con.Open(); string sqlstr = "select * from tb_tools"; SqlDataAdapter MyAdapter = new SqlDataAdapter(sqlstr, con); DataSet ds = new DataSet(); MyAdapter.Fill(ds, "tb_tools"); ps.DataSource = ds.Tables["tb_tools"].DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 2; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 this.lnkbtnUp.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnBack.Enabled = true; this.lnkbtnOne.Enabled = true; if (curpage == 1) { this.lnkbtnOne.Enabled = false;//不显示第一页按钮 this.lnkbtnUp.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { this.lnkbtnNext.Enabled = false;//不显示下一页 this.lnkbtnBack.Enabled = false;//不显示最后一页 } this.labBackPage.Text = Convert.ToString(ps.PageCount); this.dlContent.DataSource = ps; this.dlContent.DataKeyField = "ID"; this.dlContent.DataBind(); con.Close(); }
protected void renderview(object sender, EventArgs e) { GridViewRow gvr = (sender as GridView).BottomPagerRow; if (gvr != null) { gvr.Visible = true; } PagedDataSource ps = new PagedDataSource(); ps.DataSource = ods.Select(); if (ps.DataSourceCount > 0) { try { (gvr.FindControl("ddlPageSize") as DropDownList).SelectedValue = gridList.PageSize.ToString(); } catch (ArgumentOutOfRangeException ae) { (gvr.FindControl("ddlPageSize") as DropDownList).SelectedIndex = 0; } (gvr.FindControl("lblTotalRecord") as Label).Text = ps.DataSourceCount.ToString(); this.hidcurpage.Value = (gridList.PageIndex + 1).ToString(); } }
protected void datasetbind() { int currentPage; try { currentPage = Convert.ToInt32(Request.QueryString["page"]); } catch { currentPage = 1; } if (currentPage == 0) { currentPage = 1; } LiuyanOperation aop = new LiuyanOperation(); PagedDataSource ps = new PagedDataSource(); //ps.DataSource=aop. ps.DataSource = aop.viewAll();//数据源为一个链表!,如此之棒,赞~! ps.AllowPaging = true; ps.PageSize = 10; ps.CurrentPageIndex = currentPage - 1; this.Pagination1.pageCount = ps.PageCount; this.Pagination1.currentPage = currentPage; this.Pagination1.pageUrl = "Liuyan.aspx"; this.Pagination1.paramName = "page"; this.Data_list_liuyan.DataSource = ps; this.Data_list_liuyan.DataBind(); }
protected void BindList() { // edit by shiney DataTable dt = AccessHelper.ExecuteDataTable(strConnection, CommandType.Text, "SELECT * FROM FileList where IsDisplay = true"); //if (dt == null) return; if (dt.Rows.Count == 0) { dvEmpty.InnerHtml += "此栏目暂无信息"; dvbtn.Visible = false; } if (dt.Rows.Count > 0) dvbtn.Visible = true; PagedDataSource ps = new PagedDataSource(); ps.AllowPaging = true; ps.PageSize = 10; rpList.DataSource = ps; ps.CurrentPageIndex = Convert.ToInt32(this.lbCurPage.Text) - 1; ps.DataSource = dt.DefaultView; this.btnPreviousPage.Enabled = true; this.btnNextPage.Enabled = true; if (ps.CurrentPageIndex == 0) { this.btnPreviousPage.Enabled = false; } if (ps.CurrentPageIndex == ps.PageCount - 1) { this.btnNextPage.Enabled = false; } rpList.DataBind(); }
//绑定用户信息到DataList public void DataListBind() { DalOperationFeedBack dou = new DalOperationFeedBack(); DataView dv = dou.FindFeedBack().DefaultView; this.AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = AspNetPager1.PageSize; this.dlFeedBack.DataSource = pds; this.dlFeedBack.DataBind(); if (this.dlFeedBack.Items.Count == 0) { btnDelete.Visible = false; } else { btnDelete.Visible = true; } if (pds.Count > 0) { this.dlFeedBack.ShowFooter = false; } }
protected override void LoadPagedData() { List<Branch> branchesList = branchesOperator.SelectBySupplierID(Convert.ToInt32(Request.QueryString["SuppID"]), (bool?)IsArabic); if (branchesList != null && branchesList.Count > 0) { PagedDataSource pager = new PagedDataSource(); pager.DataSource = branchesList; pager.AllowPaging = true; pager.PageSize = 10; pager.CurrentPageIndex = CurrentPage; if (pager.PageCount > 1) { btnMoveNext.Visible = true; btnMovePrevious.Visible = true; btnMoveNext.Enabled = !pager.IsLastPage; btnMovePrevious.Enabled = !pager.IsFirstPage; } rptBranches.DataSource = pager; rptBranches.DataBind(); lblEmptyDataMessage.Visible = false; } else { btnMoveNext.Visible = false; btnMovePrevious.Visible = false; lblEmptyDataMessage.Visible = true; } }
void LoadData() { DataTable table = ProductsManager.CreateInstant().GetProductInCatalog(CatId, 0); //smartPager.Visible = true; if ((table == null && table.Rows.Count == 0) || (table != null && table.Rows.Count == 0) || CatId <= 0 || string.IsNullOrEmpty(TextId)) { smartPager.Visible = false; this.Visible = false; return; } pagedata = Func.GetPaging(table, Request["page"], Config.GetPagging()); this.smartPager.RowCount = pagedata.DataSourceCount; this.smartPager.CurrentPage = pagedata.CurrentPageIndex + 1; this.smartPager.PageSize = pagedata.PageSize; this.smartPager.Visible = this.smartPager.RowCount > this.smartPager.PageSize; this.smartPager.UrlFormatString = Modules.Catalogs.UrlBuilder.GetCatsByIdTextIdPagging(CatId, TextId); if (pagedata.DataSourceCount > 0) last = pagedata.DataSourceCount - 1; dltProducts.DataSource = pagedata; dltProducts.DataBind(); }
private void BindRepeater() { this.cmd.CommandText = "SELECT * FROM ForumUsers"; if (Request.QueryString["Admin"] != null) { this.cmd.CommandText += " WHERE UserID IN (SELECT UserID FROM ForumAdministrators)"; } this.cmd.CommandText += " ORDER BY UserName"; DbDataAdapter da = providerFactory.CreateDataAdapter(); da.SelectCommand = this.cmd; DataTable dt = new DataTable(); da.Fill(dt); PagedDataSource pagedSrc = new PagedDataSource(); pagedSrc.DataSource = dt.DefaultView; pagedSrc.AllowPaging = true; pagedSrc.PageSize = this.pageSize * 3; int curPage = 0; if(Request.QueryString["page"]!=null) int.TryParse(Request.QueryString["page"], out curPage); pagedSrc.CurrentPageIndex = curPage; pagerString = ""; for (int i = 0; i < pagedSrc.PageCount; i++) { if (i == curPage) pagerString += " " + (i + 1); else pagerString += " <a href=allusers.aspx?Page=" + i + ">" + (i + 1) + "</a>"; } this.rptMessagesList.DataSource = pagedSrc; this.rptMessagesList.DataBind(); }
public void dlBind() { int curpage = Convert.ToInt32(labNowPage.Text); PagedDataSource ps = new PagedDataSource(); string strSql = "SELECT * FROM tb_Reply WHERE ReplyID=" + Request["ID"].ToString() + " order by DateTime Desc"; DataTable dsTable = dbObj.GetDataSetStr(strSql, "tbReply"); ps.DataSource = dsTable.DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 3; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 lnkbtnPrve.Enabled = true; lnkbtnTop.Enabled = true; lnkbtnNext.Enabled = true; lnkbtnLast.Enabled = true; if (curpage == 1) { lnkbtnTop.Enabled = false;//不显示第一页按钮 lnkbtnPrve.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { lnkbtnNext.Enabled = false;//不显示下一页 lnkbtnLast.Enabled = false;//不显示最后一页 } this.labCount.Text = Convert.ToString(ps.PageCount); this.dlReplyWord.DataSource = ps; this.dlReplyWord.DataKeyField = "ID"; this.dlReplyWord.DataBind(); }
protected void Bind_Msg() { String strCount = "0"; String strCmd = "SELECT * FROM MsgBrd where Status = true order by CreateTime desc"; DataTable dt = AccessHelper.ExecuteDataTable(spbtzb.ConString.ConnString, CommandType.Text, strCmd); if (dt == null || dt.Rows.Count == 0) { return; } this.lbl_Count.Text = dt.Rows.Count.ToString(); dvbtn.Visible = true; PagedDataSource ps = new PagedDataSource(); ps.AllowPaging = true; ps.PageSize = 15; ps.CurrentPageIndex = Convert.ToInt32(this.lbCurPage.Text) - 1; ps.DataSource = dt.DefaultView; rp_Msgs.DataSource = ps; this.btnPreviousPage.Enabled = true; this.btnNextPage.Enabled = true; if (ps.CurrentPageIndex == 0) { this.btnPreviousPage.Enabled = false; } if (ps.CurrentPageIndex == ps.PageCount - 1) { this.btnNextPage.Enabled = false; } this.rp_Msgs.DataBind(); }
//绑定提交作业列表 public void DataBindSchoolWorks(int schoolworkNotifyId) { DalOperationAboutSchoolWorks dalOperationAboutschoolwork = new DalOperationAboutSchoolWorks(); string studentName = txtNameSearch.Text; DataView dv = null; if ((txtlow.Text != null && txtlow.Text.Length > 0) || (txthigh.Text != null && txthigh.Text.Length > 0)) { float low = (txtlow.Text == null || txtlow.Text.Equals("")) ? float.MinValue : float.Parse(txtlow.Text.Trim()); float high = (txthigh.Text == null || txtlow.Text.Equals("")) ? float.MaxValue : float.Parse(txthigh.Text.Trim()); dv = dalOperationAboutschoolwork.FindSchoolWorksByschoolWorkNofityId(schoolworkNotifyId, studentName, low, high).Tables[0].DefaultView; } else { dv = dalOperationAboutschoolwork.FindSchoolWorksByschoolWorkNofityId(schoolworkNotifyId, studentName).Tables[0].DefaultView; } this.AspNetPager2.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = CommonUtility.pageSize; this.ddlstSchoolWork.DataSource = pds; this.ddlstSchoolWork.DataBind(); if (pds.Count > 0) { this.ddlstSchoolWork.ShowFooter = false; } }
private void BindRepeater() { this.cmd.CommandText = "SELECT ForumPersonalMessages.MessageID, ForumUsers.UserName, ForumPersonalMessages.CreationDate, ForumPersonalMessages.Body, ForumUsers.UserID FROM ForumPersonalMessages INNER JOIN ForumUsers ON ForumPersonalMessages.ToUserID=ForumUsers.UserID WHERE ForumPersonalMessages.FromUserID='" + CurrentUserID + "' ORDER BY ForumPersonalMessages.CreationDate DESC"; DbDataAdapter da = providerFactory.CreateDataAdapter(); da.SelectCommand = this.cmd; DataTable dt = new DataTable(); da.Fill(dt); PagedDataSource pagedSrc = new PagedDataSource(); pagedSrc.DataSource = dt.DefaultView; pagedSrc.AllowPaging = true; pagedSrc.PageSize = this.pageSize; int curPage = 0; if(Request.QueryString["page"]!=null) int.TryParse(Request.QueryString["page"], out curPage); pagedSrc.CurrentPageIndex = curPage; //prepare a string for the "pager" at the bottom pagerString = ""; for (int i = 0; i < pagedSrc.PageCount; i++) { if (i == curPage) pagerString += " " + (i + 1); else pagerString += " <a href=\"privatemessages.aspx?Page=" + i + "\">" + (i + 1) + "</a>"; } this.rptMessagesList.DataSource = pagedSrc; this.rptMessagesList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = BLLNews.getAllNews().DefaultView; objPds.AllowPaging = true; objPds.PageSize = 2; int CurPage; if (Request.QueryString["Page"] != null) CurPage = Convert.ToInt32(Request.QueryString["Page"]); else CurPage = 1; objPds.CurrentPageIndex = CurPage - 1; //lblCurrentPage.Text = "Page: " + CurPage.ToString(); if (!objPds.IsFirstPage) lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1); if (!objPds.IsLastPage) lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1); Repeater1.DataSource = objPds; Repeater1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { dtNewsCategory = taNewsCategory.SelectNewsCategoryNameByNewsCategoryId(5); if (dtNewsCategory.Rows.Count > 0) { int page = 10; dtNews = taNews.SelectNewsbyNewsCategoryId(5); if (dtNews.Rows.Count > 0) { PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = dtNews.DefaultView; objPds.AllowPaging = true; objPds.PageSize = page; objPds.CurrentPageIndex = CurrentPage; Repeater1.DataSource = objPds; Repeater1.DataBind(); } else { Repeater1.Visible = false; } } else { Repeater1.Visible = false; } }
public void GetItems() { if (Convert.ToInt32(Session["CurrentPage"].ToString()) != 0) { CurrentPage = Convert.ToInt32(Session["CurrentPage"].ToString()); } DataTable dtDB = new DataTable("ItemInfo"); DataTable dtDB1 = new DataTable("ItemInfo1"); if ( Request.QueryString["categoryid"] == null || Request.QueryString["categoryid"]=="") { SqlDataAdapter adpDB = new SqlDataAdapter("Select productid,producttitle,sort,model,thumbNail from Product where categoryid in (select categoryid from Category where companyid=16) order by sort ", conn); adpDB.Fill(dtDB); } else { SqlDataAdapter adpDB = new SqlDataAdapter("Select productid,producttitle,sort,model,thumbNail from Product where categoryid in (select categoryid from Category where companyid=16 and categoryid=" + Request.QueryString["categoryid"] + ") order by sort ", conn); adpDB.Fill(dtDB); } PagedDataSource objPage = new PagedDataSource(); objPage.DataSource = dtDB.DefaultView; objPage.AllowPaging = true; objPage.PageSize = 100; Session["TotalPages"] = objPage.PageCount - 1; objPage.CurrentPageIndex = CurrentPage; DataList1.DataSource = objPage; DataList1.DataBind(); conn.Close(); }
public void dlBind() { int curpage = Convert.ToInt32(labNowPage.Text); //当前页 PagedDataSource ps = new PagedDataSource(); //定义一个PagedDataSource类对象 //获取留言信息 string strSql = "SELECT * FROM tb_LeaveWord WHERE Uid='" + Session["UserName"].ToString() + "'"; SqlCommand myCmd = dbObj.GetCommandStr(strSql); DataTable dsTable = dbObj.GetDataSet(myCmd, "tbLeaveWord"); ps.DataSource =dsTable.DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 10; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 lnkbtnPrve.Enabled = true; lnkbtnTop.Enabled = true; lnkbtnNext.Enabled = true; lnkbtnLast.Enabled = true; if (curpage == 1) { lnkbtnTop.Enabled = false;//不显示第一页按钮 lnkbtnPrve.Enabled = false;//不显示上一页按钮 } if (curpage == ps.PageCount) { lnkbtnNext.Enabled = false;//不显示下一页 lnkbtnLast.Enabled = false;//不显示最后一页 } this.labCount.Text = Convert.ToString(ps.PageCount);//页的总数 //绑定DataList控件,显示留言信息 this.dlMyWord.DataSource = ps; this.dlMyWord.DataKeyField = "ID"; this.dlMyWord.DataBind(); }
protected void bindSport() { //获取当前页码 int noncePage = Convert.ToInt32(labPage.Text); //创建PagedDataSource对象用来实现分页 PagedDataSource ps = new PagedDataSource(); string sqlSel = "select * from videoInfo where videoType='体育' and Auditing='1' order by videoDate desc"; //调用公共类中的getRows方法并将所返回的所有数据绑定到PagedDataSource数据源中 ps.DataSource = operateData.getRows(sqlSel).DefaultView; //设置启动分页 ps.AllowPaging = true; //设置每页显示的项数 ps.PageSize = 8; //设置当前页的索引 ps.CurrentPageIndex = noncePage - 1; this.lnkbtnFront.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnLast.Enabled = true; this.lnkbtnFirst.Enabled = true; //如果当前为第一页将不显示第一页按钮和上一页按钮 if (noncePage == 1) { this.lnkbtnFirst.Enabled = false; //不显示第一页按钮 this.lnkbtnFront.Enabled = false; //不显示上一页按钮 } //如果当前为最后一页将不显示最后一页按钮和下一页按钮 if (noncePage == ps.PageCount) { this.lnkbtnNext.Enabled = false; //不显示下一页 this.lnkbtnLast.Enabled = false; //不显示最后一页 } labBackPage.Text = Convert.ToString(ps.PageCount); dlSport.DataSource = ps; dlSport.DataBind(); }
private void fillData() { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\Extra\umang\live_resume\App_Data\Database.mdf;Integrated Security=True"); con.Open(); DataTable dt = new DataTable(); SqlDataAdapter adapt = new SqlDataAdapter("Select * from tblpost Order by Post_date", con); // SqlDataAdapter adapt = new SqlDataAdapter("select * from tblpost",con); adapt.Fill(dt); con.Close(); PagedDataSource pds = new PagedDataSource(); DataView dv = new DataView(dt); pds.DataSource = dv; pds.AllowPaging = true; pds.PageSize = 3; pds.CurrentPageIndex = PageNumber; if (pds.PageCount > 1) { rptPaging.Visible = true; ArrayList arraylist = new ArrayList(); for (int i = 0; i < pds.PageCount; i++) { arraylist.Add((i + 1).ToString()); } rptPaging.DataSource = arraylist; rptPaging.DataBind(); } else { rptPaging.Visible = false; } Repeater1.DataSource = pds; Repeater1.DataBind(); }
public void BindRepeater()//分页 { PagedDataSource pd = new PagedDataSource(); pd.AllowPaging = true; pd.PageSize = 30; int index = (int)ViewState["pageIndex"]; //BLL.Materialbll mater = new BLL.Materialbll(); pd.DataSource = new BLL.Materialbll().GetMaterial();// mater.GetMaterial(); if (index < 1) { index = pd.PageCount; } if (index > pd.PageCount) { index = 1; } pd.CurrentPageIndex = index - 1; ViewState["index"] = index; lblMsg.Text = "第" + (index) + "页/共" + pd.PageCount + "页"; dgdDataList.DataSource = pd; dgdDataList.DataBind(); }
private void binddataqc() { string sql = "select * from sy_qiche order by qcId desc"; int inCurrent = Convert.ToInt32(lblCurrent.Text); PagedDataSource pgs = new PagedDataSource(); pgs.DataSource = sybll.select_news(sql).DefaultView; pgs.AllowPaging = true; pgs.PageSize = 2; pgs.CurrentPageIndex = inCurrent - 1; lblTotal.Text = pgs.PageCount.ToString(); int zongshu = Convert.ToInt32(pgs.DataSourceCount) + 1; Label2.Text = pgs.DataSourceCount.ToString(); //获取数据源中的项数 lbtFirst.Enabled = true; lbtDown.Enabled = true; lbtUp.Enabled = true; lbtLast.Enabled = true; if (inCurrent == 1) { lbtFirst.Enabled = false; lbtUp.Enabled = false; } else { lbtLast.Enabled = true; lbtDown.Enabled = true; } if (inCurrent == pgs.PageCount) { lbtDown.Enabled = false; lbtLast.Enabled = false; } grdqc.DataSource = pgs; grdqc.DataBind(); }
//绑定后数据 private void BindDeptLog() { //初始化参数 DateTime beginTime = DateTime.Now.AddDays(-5); DateTime endTime = DateTime.Now; int deptCode = 1; // int state = 0; string patroluser = string.Empty; DataTable dt = new DataTable(); //根据指定时间范围,获取某个部门下的电子巡逻日志数据 //dt = bll.GetDeptLog(beginTime, endTime, deptCode,state); //获取全部电子巡逻日志 dt = bll.GetLogObserved("b.deptid=" + deptCode + " AND b.state=0"); if (dt != null && dt.Rows.Count > 0) { //初始化分页数据 AspNetPager1.RecordCount = dt.Rows.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dt.DefaultView; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; //绑定分页后的数据 this.gv_electroniclist.DataSource = pds; this.gv_electroniclist.DataBind(); } else { litmsg.Visible = true; litmsg.Text = "<div style='font-size:16px; font-family:微软雅黑; color:red;font-weight:bold; text-align:center;'>无相关巡逻记录!</div>"; } }
public void bindDataList()//用户自定义方法实现分页 { int curpage = Convert.ToInt32(this.labPage.Text); PagedDataSource ps = new PagedDataSource(); SqlConnection con = new SqlConnection(EP.GetConStr()); con.Open(); string sqlstr = "select * from tb_image"; SqlDataAdapter MyAdapter = new SqlDataAdapter(sqlstr, con); DataSet ds = new DataSet(); MyAdapter.Fill(ds, "tb_image"); ps.DataSource = ds.Tables["tb_image"].DefaultView; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 8; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 this.lnkbtnUp.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnBack.Enabled = true; this.lnkbtnOne.Enabled = true; if (curpage == 1) { this.lnkbtnOne.Enabled = false; //不显示第一页按钮 this.lnkbtnUp.Enabled = false; //不显示上一页按钮 } if (curpage == ps.PageCount) { this.lnkbtnNext.Enabled = false; //不显示下一页 this.lnkbtnBack.Enabled = false; //不显示最后一页 } this.labBackPage.Text = Convert.ToString(ps.PageCount); this.dlTouxiang.DataSource = ps; this.dlTouxiang.DataKeyField = "ID"; this.dlTouxiang.DataBind(); con.Close(); }
//获得用户列表 public void getRolesList(string strRole) { try { DataTable dt = RolesJurisdictionBLL.GetRolesJurisdictionList(strRole); //dvList.DataSource = dt; //dvList.DataBind(); //rptRolesJurisdiction PagedDataSource pds = new PagedDataSource(); pds.DataSource = dt.DefaultView; pds.AllowPaging = true; pds.PageSize = this.anpList.PageSize; pds.CurrentPageIndex = this.anpList.CurrentPageIndex - 1; this.anpList.RecordCount = dt.Rows.Count; rptRolesJurisdiction.DataSource = pds; rptRolesJurisdiction.DataBind(); } catch (Exception exc) { //异常处理 } }
public void bindNews(string id) { int curpage = Convert.ToInt32(labPage1); PagedDataSource ps = new PagedDataSource(); IList <PolicyArticle> searchtab = policyarticlebll.search(id); if (searchtab == null || searchtab.Count == 0) { if (IsPostBack) { Response.Write("<script lanuage=javascript>alert('没有你要找的关键字!')</script>"); } return; } ps.DataSource = searchtab; ps.AllowPaging = true; //是否可以分页 ps.PageSize = 10; //显示的数量 ps.CurrentPageIndex = curpage - 1; //取得当前页的页码 this.lnkbtnUp.Enabled = true; this.lnkbtnNext.Enabled = true; this.lnkbtnBack.Enabled = true; this.lnkbtnOne.Enabled = true; if (curpage == 1) { this.lnkbtnOne.Enabled = false; //不显示第一页按钮 this.lnkbtnUp.Enabled = false; //不显示上一页按钮 } if (curpage == ps.PageCount) { this.lnkbtnNext.Enabled = false; //不显示下一页 this.lnkbtnBack.Enabled = false; //不显示最后一页 } this.labBackPage.Text = Convert.ToString(ps.PageCount); this.rightlist.DataSource = ps; this.rightlist.DataBind(); }
private void fill_featured() { int k = 0; dsfeatured = access.GetDataSet("select * from dbo.FrontFeaturedProduct(1)", CommandType.Text, null); if (dsfeatured.Tables[0].Rows.Count > 0) { featurephotopath = new string[dsfeatured.Tables[0].Rows.Count]; foreach (DataRow d in dsfeatured.Tables[0].Rows) { featurephotopath[k] = d["items"].ToString(); k++; } PagedDataSource pgdtsrc = new PagedDataSource(); pgdtsrc.DataSource = featurephotopath; pgdtsrc.AllowPaging = true; pgdtsrc.PageSize = 3; pgdtsrc.CurrentPageIndex = CurrentPage - 1; imgbtnlft.Enabled = !pgdtsrc.IsFirstPage; imgbtnright.Enabled = !pgdtsrc.IsLastPage; dtlstFeatured.DataSource = pgdtsrc; dtlstFeatured.DataBind(); } }
protected void BindRepeater() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["WY-FADBConnectionString"].ConnectionString.ToString()); SqlCommand cmd = new SqlCommand("SELECT * FROM ClassingFA where exists (SELECT ClassName FROM FA_Class where ClassName=@ClassName and FA_Class.Class_ID=ClassingFA.Class_ID)", con); cmd.Parameters.AddWithValue("ClassName", DropDownList1.Text); if (con.State == ConnectionState.Closed) { con.Open(); } DataTable dt = new DataTable(); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(dt); PagedDataSource pgitems = new PagedDataSource(); DataView dv = new DataView(dt); pgitems.DataSource = dv; pgitems.AllowPaging = true; pgitems.PageSize = 10; pgitems.CurrentPageIndex = PageNumber; if (pgitems.PageCount > 1) { rptPaging.Visible = true; ArrayList pages = new ArrayList(); for (int i = 0; i < pgitems.PageCount; i++) pages.Add((i + 1).ToString()); rptPaging.DataSource = pages; rptPaging.DataBind(); } else { rptPaging.Visible = false; } rptResult.DataSource = pgitems; rptResult.DataBind(); }
public void VirtualPager2() { PagedDataSource paged = new PagedDataSource(); paged.AllowPaging = true; paged.PageSize = 100; paged.VirtualCount = 50; paged.AllowCustomPaging = true; DataTable table = new DataTable(); FillTable(table, 100); paged.DataSource = new DataView(table); int count = 0; IEnumerator rator = paged.GetEnumerator(); while (rator.MoveNext()) { count++; } Assert.AreEqual(100, count, "count"); Assert.AreEqual(true, paged.IsFirstPage, "first"); Assert.AreEqual(true, paged.IsLastPage, "last"); }
/// <summary> /// The bind data. /// </summary> private void BindData() { this.PagerTop.PageSize = YafContext.Current.BoardSettings.AlbumsPerPage; // set the Datatable var albumListDT = DB.album_list(this.UserID, null); if ((albumListDT != null) && (albumListDT.Rows.Count > 0)) { this.PagerTop.Count = albumListDT.Rows.Count; // create paged data source for the albumlist var pds = new PagedDataSource { DataSource = albumListDT.DefaultView, AllowPaging = true, CurrentPageIndex = this.PagerTop.CurrentPageIndex, PageSize = this.PagerTop.PageSize }; this.Albums.DataSource = pds; this.DataBind(); } }
void DataBindToRepeater(int currentPage) { string sql = "select * from Friend where myusername='******' "; DataTable dt = new DataTable(); dt = myfriend.select(sql); PagedDataSource pds = new PagedDataSource(); pds.AllowPaging = true; pds.PageSize = 5; pds.DataSource = dt.DefaultView; lbTotal.Text = pds.PageCount.ToString(); pds.CurrentPageIndex = currentPage - 1;//当前页数从零开始,故把接受的数减一 rptfriend.DataSource = pds; rptfriend.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { DataTable dthaber = klas.GetDataTable("SELECT dbo.Icerikler.*, dbo.Kullanici.AdSoyad FROM dbo.Icerikler INNER JOIN dbo.Kullanici ON dbo.Icerikler.KullaniciId = dbo.Kullanici.KullaniciId where dbo.Icerikler.TurId=5 and dbo.Icerikler.Onay=1 order by [IcerikId] desc"); PagedDataSource pds = new PagedDataSource(); pds.DataSource = dthaber.DefaultView; pds.AllowPaging = true; pds.PageSize = 5; int currentPage; if (Request.QueryString["page"] != null) { currentPage = Int32.Parse(Request.QueryString["page"]); } else { currentPage = 1; } pds.CurrentPageIndex = currentPage - 1; Label1.Text = "Sayfa: " + currentPage + " / " + pds.PageCount; if (!pds.IsFirstPage) { linkPrev.NavigateUrl = "HaberListe.aspx?page=" + (currentPage - 1); } if (!pds.IsLastPage) { linkNext.NavigateUrl = "HaberListe.aspx?page=" + (currentPage + 1); } rphaber.DataSource = pds; rphaber.DataBind(); }
//分页 protected void Staiont() { PagedDataSource pd = new PagedDataSource(); pd.AllowPaging = true; pd.PageSize = 4; BLL.DormitoryBLL dormitoryBll = new BLL.DormitoryBLL(); pd.DataSource = dormitoryBll.GetDormitoryBLL(0); int index = (int)ViewState["PageIndex"]; if (index < 1) { index = pd.PageCount; } if (index > pd.PageCount) { index = 1; } pd.CurrentPageIndex = index - 1; lblPage.Text = "第" + (index) + "页/共" + pd.PageCount + "页"; dgdShowDormitory.DataSource = pd; dgdShowDormitory.DataBind(); }
public void databind(string id) { con.Open(); SqlCommand com = con.CreateCommand(); com.CommandText = "Select Item_Id,Image,MRP,SalePrice,Item_Name from dbo.Item Where Sub_Category_Id=@Id and Active=@ac and In_Stock-Out_Stock > 0"; com.Parameters.AddWithValue("@Id", id); com.Parameters.AddWithValue("@ac", "yes"); dadapter = new SqlDataAdapter(com); dset = new DataSet(); adsource = new PagedDataSource(); dadapter.Fill(dset); adsource.DataSource = dset.Tables[0].DefaultView; adsource.PageSize = 4; adsource.AllowPaging = true; adsource.CurrentPageIndex = pos; btnfirst.Visible = !adsource.IsFirstPage; btnprevious.Visible = !adsource.IsFirstPage; btnlast.Visible = !adsource.IsLastPage; btnnext.Visible = !adsource.IsLastPage; DataList2.DataSource = adsource; DataList2.DataBind(); con.Close(); }
private void RptBind(string strWhere) { Cms.DAL.ProductInfo dal = new Cms.DAL.ProductInfo(); DataSet ds = dal.GetProductList(strWhere); DataView dv = ds.Tables[0].DefaultView; //利用PAGEDDAGASOURCE类来分页 PagedDataSource pds = new PagedDataSource(); AspNetPager1.RecordCount = dv.Count; pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; //获得总条数 pcount = dv.Count; if (this.pcount < 0) { this.lbmsg.Visible = true; this.lbmsg.Text = "暂时没有产品"; } //绑定数据 rptList.DataSource = pds; rptList.DataBind(); }
protected void btnShowAll_Click(object sender, EventArgs e) { txtTitle.Text = ""; dropStatus.SelectedIndex = 0; dropStatus.SelectedIndex = 0; DataTable dt = NewsBll.getAllNews(); if (dt.Rows.Count > 0) { AspNetPager1.RecordCount = dt.Rows.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dt.DefaultView; pds.PageSize = AspNetPager1.PageSize; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; dgNews.DataSource = pds; dgNews.DataBind(); } else { dgNews.DataSource = null; dgNews.DataBind(); } }
public void binddr() { try { string[] ArrX; string sqlstr = "select * from h_fangyuan where 2>1 "; if (fujia.Text == "") { if (fybh.Text != "") { sqlstr = sqlstr + " and 编号 like '%" + PageValidate.ToLikeSql(fybh.Text.ToString().Trim()) + "%'"; } if (TextBox1.Text != "") { sqlstr = sqlstr + " and 辖区 like '%" + PageValidate.ToLikeSql(TextBox1.Text.ToString().Trim()) + "%'"; } if (TextBox2.Text != "") { sqlstr = sqlstr + " and 街道 like '%" + PageValidate.ToLikeSql(TextBox2.Text.ToString().Trim()) + "%'"; } if (TextBox3.Text != "") { sqlstr = sqlstr + " and 小区 like '%" + PageValidate.ToLikeSql(TextBox3.Text.ToString().Trim()) + "%'"; } if (TextBox4.Text != "") { sqlstr = sqlstr + " and 房屋户型 like '%" + PageValidate.ToLikeSql(TextBox4.Text.ToString().Trim()) + "%'"; } if (TextBox5.Text != "") { ArrX = TextBox5.Text.ToString().Trim().Split('-'); if (ArrX.Length == 1) { sqlstr = sqlstr + " and 建筑面积 = '" + ArrX[0] + "'"; } else if (ArrX.Length == 2) { sqlstr = sqlstr + " and (建筑面积 >= '" + isnull(ArrX[0], "0") + "' and 建筑面积 <= '" + isnull(ArrX[1], "10000000000000") + "')"; } } if (TextBox6.Text != "") { ArrX = TextBox6.Text.ToString().Trim().Split('-'); if (ArrX.Length == 1) { sqlstr = sqlstr + " and 第层 = '" + ArrX[0] + "'"; } else if (ArrX.Length == 2) { sqlstr = sqlstr + " and (第层 >= '" + isnull(ArrX[0], "0") + "' and 第层 <= '" + isnull(ArrX[1], "1000") + "')"; } } if (TextBox7.Text != "") { ArrX = TextBox7.Text.ToString().Trim().Split('-'); if (ArrX.Length == 1) { sqlstr = sqlstr + " and 房主报价 = '" + ArrX[0] + "'"; } else if (ArrX.Length == 2) { sqlstr = sqlstr + " and (房主报价 >= '" + isnull(ArrX[0], "0") + "' and 房主报价 <= '" + isnull(ArrX[1], "1000000000") + "')"; } } } else { ArrX = fujia.Text.ToString().Trim().Split('-'); if (ArrX.Length == 1) { sqlstr = sqlstr + " and (编号 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 辖区 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 街道 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 小区 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 房屋户型 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 产权性质 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 产权证 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or name like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 部门 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 详细地址 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 公交线路 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 环境描述 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 建筑结构 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 使用性质 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 建筑年代 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 房屋现状 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 房屋类型 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 装修状况 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 配套设施 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%' or 房源备注 like '%" + PageValidate.ToLikeSql(fujia.Text.ToString().Trim()) + "%')"; } else if (ArrX.Length == 2) { sqlstr = sqlstr + " and ((建筑面积 >= '" + isnull(ArrX[0], "0") + "' and 建筑面积 <= '" + isnull(ArrX[1], "10000000000000") + "') or (第层 >= '" + isnull(ArrX[0], "0") + "' and 第层 <= '" + isnull(ArrX[1], "1000") + "') or (房主报价 >= '" + isnull(ArrX[0], "0") + "' and 房主报价 <= '" + isnull(ArrX[1], "1000000000") + "'))"; } } if (DropDownList1.SelectedValue != "不限") { sqlstr = sqlstr + " and 售租形式 = '" + DropDownList1.SelectedValue + "'"; } sqlstr = sqlstr + "and 成交状况='未成交' order by ID desc ;"; DataView dv = DbHelperSQL.Query(sqlstr).Tables[0].DefaultView; PagedDataSource pds = new PagedDataSource(); AspNetPager1.RecordCount = dv.Count; pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; this.Repeater1.DataSource = pds; this.Repeater1.DataBind(); } catch (Exception ex) { if (ex != null) { MessageBox.Show(this, "查询条件输入不符合规则,请重新输入!"); return; } } }
private void Paging() { #region page for repeater // Starting paging here. PagedDataSource pds = new PagedDataSource(); DataView dt = tourModel.tourhotTuan().DefaultView; pds.DataSource = dt; pds.AllowPaging = true; // Show number of product in one page. pds.PageSize = 5; // Specify sum of page. int numPage = pds.PageCount; int currentPage; if (Request.QueryString["page"] != null) { currentPage = Int32.Parse(Request.QueryString["page"]); } else { currentPage = 1; } // Because paging always start at 0. pds.CurrentPageIndex = currentPage - 1; // Show // Labelnv.Text = "Trang " + currentPage + " cua " + pds.PageCount; string urls = "<ul class='pagination'>"; for (int i = 1; i <= numPage; i++) { if (i != currentPage) { urls += "<li><a href='" + Request.CurrentExecutionFilePath + "?page=" + i + "'>" + i + "</a></li>"; } else { urls += "<li class='active'><a href='" + Request.CurrentExecutionFilePath + "?page=" + i + "'>" + i + "</a></li>"; } } url.Text = urls + "</ul>"; // Config next - pre link. /* if (!pds.IsFirstPage) * { * lnkPre.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentPage - 1); * lnkStart.NavigateUrl = Request.CurrentExecutionFilePath + "?page=1"; * * * } * else * { * * lnkPre.Visible = false; * } * if (!pds.IsLastPage) * { * lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentPage + 1); * lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + numPage; * lnkEnd.Text = numPage.ToString(); * } * else * { * lnkEnd.Text = numPage.ToString(); * lnkNext.Visible = false; * } * if (numPage < 2) * { * Labelnv.Visible = false; * lnkStart.Visible = false; * lnkEnd.Visible = false; * }*/ #endregion rptTour.DataSource = pds; rptTour.DataBind(); }
private void LoadItems(List <CartItems> Cartinfo) { DataTable CartDT = new DataTable();//data to be bound to cart datalist DataColumn dcId = new DataColumn("ItemId", typeof(long)); CartDT.Columns.Add(dcId); DataColumn dcPath = new DataColumn("ImagePath", typeof(string)); CartDT.Columns.Add(dcPath); DataColumn dcNme = new DataColumn("ItemName", typeof(string)); CartDT.Columns.Add(dcNme); DataColumn dcQy = new DataColumn("Qty", typeof(int)); CartDT.Columns.Add(dcQy); DataColumn dcBr = new DataColumn("BilledRate", typeof(float)); CartDT.Columns.Add(dcBr); DataColumn dcTr = new DataColumn("TotalRate", typeof(float)); CartDT.Columns.Add(dcTr); DataColumn dcSz = new DataColumn("Size", typeof(string)); CartDT.Columns.Add(dcSz); DataSet ds = new DataSet(); DataTable dtv = new DataTable(); DataTable dtg = new DataTable(); //InterfacesBS.InterfacesBL.InterfaceItems callCache = new ItemsClass(); budhashop.CLASS.CallCache callCache = new budhashop.CLASS.CallCache(); ds = callCache.getCache(); dtv = ds.Tables[0]; dtg = ds.Tables[1]; //create cache for group items and store here and loop throuh groups if groupChk is true in session list float totalPrice = 0; foreach (object cartObj in Cartinfo) { CartItems item = cartObj as CartItems; int cid = item.ItemId; int qty = item.Qty; string Size = ""; if (item.TypeCheck != "undefined") { Size = "Size : " + item.TypeCheck; } bool grpId = item.GrpChk; // finding the data item if (grpId) { var itemDetails = dtg.AsEnumerable().First(p => p.Field <long>("GroupId") == cid); if (itemDetails != null) { DataRow dr = CartDT.NewRow(); dr[0] = itemDetails["GroupId"]; dr[1] = itemDetails["ImagePath"];//change this to actual image path when done dr[2] = itemDetails["GroupName"]; dr[3] = qty; dr[4] = float.Parse(itemDetails["BilledRate"].ToString()); float totRate = qty * (float.Parse(itemDetails["BilledRate"].ToString())); dr[5] = totRate; dr[6] = Size; totalPrice += totRate; CartDT.Rows.Add(dr); } } else { var itemDetails = dtv.AsEnumerable().First(p => p.Field <long>("ItemId") == cid); if (itemDetails != null) { DataRow dr = CartDT.NewRow(); dr[0] = itemDetails["ItemId"]; dr[1] = itemDetails["ImagePath"]; dr[2] = itemDetails["ItemName"]; dr[3] = qty; dr[4] = float.Parse(itemDetails["BilledRate"].ToString()); float totRate = qty * (float.Parse(itemDetails["BilledRate"].ToString())); dr[5] = totRate; dr[6] = Size; totalPrice += totRate; CartDT.Rows.Add(dr); } } // updating the data row from the itemDetails object. } if (CartDT != null) { DataView dv = new DataView(); PagedDataSource pagedData = new PagedDataSource(); int rowCnt = CartDT.Rows.Count; noOfItemsLbl2.Text = rowCnt.ToString(); totalLbl2.Text = totalPrice.ToString(); dv = CartDT.DefaultView; pagedData.DataSource = dv; //pagedData.AllowPaging = true; //pagedData.PageSize = 4; pagedData.CurrentPageIndex = 0; itemCartDL.DataSource = pagedData; itemCartDL.DataBind(); } else { itemCartDL.DataSource = ""; itemCartDL.DataBind(); } }
public void get_datatable() { //数据库连接字符串 //string strconn = System.Configuration.ConfigurationManager.AppSettings["MovieConnectionString"]; //实例化连接对象,并赋值strconn SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MovieConnectionString"].ConnectionString); //打开连接对象 conn.Open(); //临时存储 // DataTable Temp_dt = new DataTable(); DataSet ds = new DataSet(); //实例化数据库适配器 SqlDataAdapter Dad = new SqlDataAdapter("select * from[Table]", conn); //填充 Dad.Fill(ds, "t"); PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables["t"].DefaultView; pds.AllowPaging = true; pds.PageSize = 1; pds.CurrentPageIndex = 1; //******** int CurPage; if (Request.QueryString["Page"] != null) { CurPage = Convert.ToInt32(Request.QueryString["Page"]); } else { CurPage = 1; } pds.CurrentPageIndex = CurPage - 1; int Count = pds.PageCount; lblMssg.Text = "当前页:" + CurPage.ToString(); lblPage.Text = Count.ToString(); if (!pds.IsFirstPage) { this.first.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1"; this.last.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(Count - 1);; up.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1); } else { this.first.Visible = false; this.last.Visible = false; } if (!pds.IsLastPage) { next.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1); } else { this.first.Visible = false; this.last.Visible = false; } //******** UserInfoRep.DataSource = pds; UserInfoRep.DataBind(); //关闭连接对象 //conn.Close(); //释放连接对象资源 //conn.Dispose(); //返回DataTable //return pds; }
protected void DataBind_DL(string ReqPage, string beginDate, string endDate, string keywords) { string strSql = string.Format("select * from v_Activity_Reply (nolock)"); strSql += " where 1=1 "; if (!string.IsNullOrEmpty(Request["Idx"])) { strSql += string.Format(" and activityIdx_FX={0}", Request["Idx"]); } strSql += " order by 1 desc"; DataSet ds = SqlHelper.ExecuteDataset(System.Data.CommandType.Text, strSql); PagedDataSource Pgds = new PagedDataSource(); Pgds.DataSource = ds.Tables[0].DefaultView; Pgds.AllowPaging = true; Pgds.PageSize = 3; lblTotalPage.Text = Pgds.PageCount.ToString(); //显示总共页数 int CurrentPage; if (ReqPage != null) { CurrentPage = Convert.ToInt32(ReqPage); } else { CurrentPage = 1; } // 当前页所引为页码-1 Pgds.CurrentPageIndex = CurrentPage - 1; // 显示当前页码 lblCurrentPage.Text = CurrentPage.ToString(); // 如果不是第一页,通过参数Page设置上一页为当前页-1,否则不显示连接 LinkButtonPrev.Enabled = true; LinkButtonNext.Enabled = true; if (Pgds.IsFirstPage) { LinkButtonPrev.Enabled = false; } // 如果不是最后一页,通过参数Page设置下一页为当前页+1,否则不显示连接 if (Pgds.IsLastPage) { LinkButtonNext.Enabled = false; } ////==========绑定下拉框页数 ddlPageCount.Items.Clear(); for (int i = 1; i < Pgds.PageCount + 1; i++) { ddlPageCount.Items.Add(i.ToString()); if (CurrentPage == Convert.ToInt32(ddlPageCount.Items[i - 1].Value)) { ddlPageCount.Items[i - 1].Selected = true; } } // 模板绑定数据源 //recordCount = ds.Tables[0].Rows.Count.ToString(); this.Repeater1.DataSource = Pgds; //new person6BLL.Admin.UserLoginLog().GetDs_UserLoginLog(beginDate, endDate, keywords); this.Repeater1.DataBind(); }
private void BindData() { TheExamName = new ExamBLL().GetThExamInfoByTheId(TheExamId.ToString()).TheExamName; //var SchRes = (from p in db.proc_GetBkgxNowYear() // select p).ToList().First(); //List<StuGradeInf> ExamRes; //ExamRes = (from p in db.StuGradeInf() // where p.zkzh != null && p.TestSubjectNo.ToString().Contains(TestSubjectNo) && p.subNum.Contains(subNum) // orderby p.TestSubjectNo, p.proOrder // select p).ToList(); //查询当前次的所有学生的成绩 var AllStuInTheExamGrade = (from p in db.Student join b in db.StuExam on p.StudentId equals b.StudentId join c in db.Paper on b.PaperId equals c.PaperId join d in db.Exam on c.ExamId equals d.ExamId join e in db.TheExam on d.TheExamId equals e.TheExamId where (e.TheExamId == TheExamId) && (p.StudentId.Contains(Query) || p.StudentName.Contains(Query) || p.Class.Contains(Query)) orderby p.Class, b.Score descending select new { stuno = p.StudentId, stname = p.StudentName, stuclass = p.Class, stuscore = b.Score, TheExamName = e.TheExamName, beginTIme = b.BeginExamTIme, endTime = b.ReplyEndTime }).ToList(); // 数据源 PagedDataSource Pgds = new PagedDataSource(); // Pgds.DataSource = AllStuInTheExamGrade; // 设置允许分页 Pgds.AllowPaging = true; // 每页显示为15行 Pgds.PageSize = 15; // 显示总共页数 // lblTotalPage.Text = Pgds.PageCount.ToString(); // 当前页 int CurrentPage; // 请求页码为不为null设置当前页,否则为第一页 if (Request.QueryString["Page"] != null) { CurrentPage = Convert.ToInt32(Request.QueryString["Page"]); } else { CurrentPage = 1; } // 当前页所引为页码-1 Pgds.CurrentPageIndex = CurrentPage - 1; // 显示当前页码 lblCurrentPage.Text = CurrentPage.ToString(); // 如果不是第一页,通过参数Page设置上一页为当前页-1,否则不显示连接 if (!Pgds.IsFirstPage) { // Request.CurrentExecutionFilePath为当前请求虚拟路径 lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurrentPage - 1) + "&Query=" + Query; } // End If // 如果不是最后一页,通过参数Page设置下一页为当前页+1,否则不显示连接 if (!Pgds.IsLastPage) { // Request.CurrentExecutionFilePath为当前请求虚拟路径 lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurrentPage + 1) + "&Query=" + Query; } // 模板绑定数据源 rp_GradeInfo.DataSource = Pgds; rp_GradeInfo.DataBind(); }
/// <summary> /// Bind repeater. /// </summary> private void BindLeaderboard() { try // try to handle BindLeaderboard { int parsedUserId = -1, parsedGroupId = -1; int?groupId = null, userId = null, friendsOfId = null; if (_settings.LeaderboardMode == LeaderboardMode.GroupMembers) { if (Int32.TryParse(Request.QueryString["GroupId"], out parsedGroupId)) { groupId = parsedGroupId; } } if (_settings.LeaderboardMode == LeaderboardMode.UserProfile) { if (Int32.TryParse(Request.QueryString["UserId"], out parsedUserId)) { userId = parsedUserId; } } if (_settings.LeaderboardMode == LeaderboardMode.UserCurrent) { userId = UserInfo.UserID; } if (_settings.LeaderboardMode == LeaderboardMode.FriendsProfile) { if (Int32.TryParse(Request.QueryString["UserId"], out parsedUserId)) { friendsOfId = parsedUserId; } } if (_settings.LeaderboardMode == LeaderboardMode.FriendsCurrent) { friendsOfId = UserInfo.UserID; } int total = -1; // define leaderboard total records int portalId = (_settings.PortalId < 0 ? PortalId : _settings.PortalId); List <ScoringLeaderboard> dataSource = UnitOfWork.UserActivitiesLog.GetLeaderboard ( portalId, userId, groupId, friendsOfId, CurrentPage * _settings.PageSize, _settings.PageSize, out total ); var source = new PagedDataSource { DataSource = dataSource, VirtualCount = total }; { source.AllowPaging = true; source.AllowServerPaging = true; // define allow server paging } source.PageSize = _settings.PageSize; source.CurrentPageIndex = CurrentPage; { ViewState["TotalPages"] = source.PageCount; } pnlPagination.Visible = (source.PageCount > 1 && _settings.ShowPaging); // define navigation enabled { btnPrevious.Enabled = !source.IsFirstPage; btnNext.Enabled = !source.IsLastPage; } lblTotal.Text = String.Format // build total label text ( @"{0} {1} {2} {3}", LocalizeString("Page.Label"), (CurrentPage + 1), LocalizeString("PageOf.Label"), source.PageCount ); rptLeaderboard.DataSource = source; { rptLeaderboard.DataBind(); // bind repeater } } catch (Exception ex) // catch exceptions { Exceptions.ProcessModuleLoadException(this, ex); } }
private void listPage() { if (Request.QueryString["Class"] != null) { ClassName = Request.QueryString["Class"].ToString(); String strConn = ConfigurationManager.ConnectionStrings["28dayConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(strConn); con.Open(); DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(" select * from L_Newss where ClassId='" + CID + "' order by Time DESC", con); sda.Fill(ds, "L_Newss"); //查询总记录 // int countNews; String sqlCount = "select count(*) from L_Newss where ClassId='" + CID + "'"; int countNews = (int)new SqlCommand(sqlCount, con).ExecuteScalar(); countRecord.Text = countNews + ""; //分页数据源 PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables["L_Newss"].DefaultView; pds.AllowPaging = true; //允许分页 pds.PageSize = 12; //单页显示项数 int CurPage; if (Request.QueryString["Page"] != null) { CurPage = Convert.ToInt32(Request.QueryString["Page"]); } else { CurPage = 1; } pds.CurrentPageIndex = CurPage - 1; //总页数 Count = pds.PageCount; CurrentPage.Text = " " + CurPage.ToString(); labPage.Text = Count.ToString(); if (!pds.IsFirstPage) { this.first.NavigateUrl = Request.CurrentExecutionFilePath + "?Class=" + ClassName + "&Page=1"; // this.last.NavigateUrl = Request.CurrentExecutionFilePath + "?Class=" + ClassName + "&Page=" + Convert.ToString(Count - 1); ; up.NavigateUrl = Request.CurrentExecutionFilePath + "?Class=" + ClassName + "&Page=" + Convert.ToString(CurPage - 1); td1.BgColor = "#c9c9c9"; td2.BgColor = "#c9c9c9"; } else { // this.first.Visible = false; } if (!pds.IsLastPage) { td3.BgColor = "#c9c9c9"; td4.BgColor = "#c9c9c9"; next.NavigateUrl = Request.CurrentExecutionFilePath + "?Class=" + ClassName + "&Page=" + Convert.ToString(CurPage + 1); last.NavigateUrl = Request.CurrentExecutionFilePath + "?Class=" + ClassName + "&Page=" + Convert.ToString(Count); } else { // this.first.Visible = false; // this.last.Visible = false; } Repeater2.DataSource = pds; Repeater2.DataBind(); } }
/// <summary> /// repeater分页并绑定 /// </summary> private void NewsBind() { string condition = ""; if (Request.QueryString["qj"] != null) { condition += "&qj=" + Request.QueryString["qj"].ToString(); } if (Request.QueryString["jz"] != null) { condition += "&jz=" + Request.QueryString["jz"].ToString(); } if (Request.QueryString["dw"] != null) { condition += "&dw=" + Server.UrlEncode(Request.QueryString["dw"].ToString()); } if (Request.QueryString["qywh"] != null) { condition += "&qywh=" + Server.UrlEncode(Request.QueryString["qywh"].ToString()); } if (Request.QueryString["gdzt"] != null) { condition += "&gdzt=" + Request.QueryString["gdzt"].ToString(); } if (Request.QueryString["zgid"] != null) { condition += "&zgid=" + Request.QueryString["zgid"].ToString(); } DataTable dt = GetDataTable("select * from dlysxx "); try { PagedDataSource objPage = new PagedDataSource(); objPage.DataSource = dt.DefaultView; objPage.AllowPaging = true; objPage.PageSize = 10; int CurPage, pagesize; if (Request.QueryString["Page"] != null) { CurPage = Convert.ToInt32(Request.QueryString["page"]); } else { CurPage = 1; } if (Request.QueryString["pagesize"] != null) { pagesize = Convert.ToInt32(Request.QueryString["pagesize"]); } else { pagesize = 10; } objPage.PageSize = pagesize; objPage.CurrentPageIndex = CurPage - 1; repData.DataSource = objPage; //这里更改控件名称 repData.DataBind(); //这里更改控件名称 RecordCount.Text = objPage.DataSourceCount.ToString(); PageCount.Text = objPage.PageCount.ToString(); Pageindex.Text = CurPage.ToString(); Literal1.Text = PageList(objPage.PageCount, CurPage, condition, pagesize); FirstPage.NavigateUrl = Request.CurrentExecutionFilePath + "?page=1&pagesize=" + pagesize.ToString() + condition; PrevPage.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (CurPage - 1) + "&pagesize=" + pagesize.ToString() + condition; NextPage.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (CurPage + 1) + "&pagesize=" + pagesize.ToString() + condition; LastPaeg.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + objPage.PageCount.ToString() + "&pagesize=" + pagesize.ToString() + condition; if (CurPage <= 1 && objPage.PageCount <= 1) { FirstPage.NavigateUrl = "javascript:void(0);"; PrevPage.NavigateUrl = "javascript:void(0);"; NextPage.NavigateUrl = "javascript:void(0);"; LastPaeg.NavigateUrl = "javascript:void(0);"; } if (CurPage <= 1 && objPage.PageCount > 1) { FirstPage.NavigateUrl = "javascript:void(0);"; PrevPage.NavigateUrl = "javascript:void(0);"; } if (CurPage >= objPage.PageCount) { NextPage.NavigateUrl = "javascript:void(0);"; LastPaeg.NavigateUrl = "javascript:void(0);"; } } catch (Exception error) { Response.Write(error.ToString()); } }
/* */ public void BindComments() { //load detailed data for entry item string strSQL; string myConnectString; //get connect string myConnectString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;; //query item and user details for entry strSQL = "SELECT tblUser.txtEmail, tblUser.txtUserName, tblUser.userDir, tblUser.profilePic, tblBlog_dtl.comment_dt as dPosted, tblBlog_dtl.comment as txtComment FROM tblUser INNER JOIN tblBlog_dtl ON tblUser.Id = tblBlog_dtl.iUser WHERE tblBlog_dtl.blogId = '" + hdnbId.Value + "'"; SqlConnection myConnection = new SqlConnection(myConnectString); //Declare Dataset DataSet dsItems = new DataSet(); //Set adapter and with connection handle SqlDataAdapter objAdapter = new SqlDataAdapter(strSQL, myConnection); try { //Fill DataSet objAdapter.Fill(dsItems, "tblBlog_dtl"); //Get result count for paging int listCount = dsItems.Tables["tblBlog_dtl"].Rows.Count; if (listCount > 0) { dlCommentList.DataBind(); lblCommentCount.Text = string.Empty; lblCommentCount.Text += (listCount == 1) ? listCount.ToString() + " Comment" : listCount.ToString() + " Comments"; } else { lblCommentCount.Text = "Be the first comment!"; lblCommentCount.ForeColor = Color.White; } pnlCommentBox.Visible = true; PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = dsItems.Tables[0].DefaultView; //bind to DataList control dlCommentList.DataSource = objPds; //dlCommentList.DataSource = dsItems; dlCommentList.DataBind(); } catch (Exception ex) { ErrorLog.ErrorRoutine(false, "BlogDetails:BindComments(): " + ex.Message); ErrorLog.ErrorRoutine(false, "BlogDetails:BindComments():InnerEx: " + ex.InnerException); classes.Email.SendEmail("BH Error", "*****@*****.**", "BlogDetails:BindComments(): " + ex.Message); } finally { myConnection.Close(); } if (Session["LoggedIn"].ToString() == "No") { pnlLoginMsg.Visible = true; btnPostComment.Enabled = false; } else { btnPostComment.Enabled = true; } }
public string Parse(int currentPageIndex, int pageCount) { var parsedContent = string.Empty; contextInfo.PageItemIndex = currentPageIndex * displayInfo.PageNum; try { if (node != null) { if (dataSet != null) { var objPage = new PagedDataSource();//分页类 objPage.DataSource = dataSet.Tables[0].DefaultView; if (pageCount > 1) { objPage.AllowPaging = true; objPage.PageSize = displayInfo.PageNum;//每页显示的项数 } else { objPage.AllowPaging = false; } objPage.CurrentPageIndex = currentPageIndex;//当前页的索引 if (displayInfo.Layout == ELayout.None) { var rptContents = new Repeater(); rptContents.ItemTemplate = new RepeaterTemplate(displayInfo.ItemTemplate, displayInfo.SelectedItems, displayInfo.SelectedValues, displayInfo.SeparatorRepeatTemplate, displayInfo.SeparatorRepeat, pageInfo, EContextType.Comment, contextInfo); if (!string.IsNullOrEmpty(displayInfo.HeaderTemplate)) { rptContents.HeaderTemplate = new SeparatorTemplate(displayInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(displayInfo.FooterTemplate)) { rptContents.FooterTemplate = new SeparatorTemplate(displayInfo.FooterTemplate); } if (!string.IsNullOrEmpty(displayInfo.SeparatorTemplate)) { rptContents.SeparatorTemplate = new SeparatorTemplate(displayInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(displayInfo.AlternatingItemTemplate)) { rptContents.AlternatingItemTemplate = new RepeaterTemplate(displayInfo.AlternatingItemTemplate, displayInfo.SelectedItems, displayInfo.SelectedValues, displayInfo.SeparatorRepeatTemplate, displayInfo.SeparatorRepeat, pageInfo, EContextType.Comment, contextInfo); } rptContents.DataSource = objPage; rptContents.DataBind(); if (rptContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(rptContents); } } else { var pdlContents = new ParsedDataList(); //设置显示属性 TemplateUtility.PutContentsDisplayInfoToMyDataList(pdlContents, displayInfo); //设置列表模板 pdlContents.ItemTemplate = new DataListTemplate(displayInfo.ItemTemplate, displayInfo.SelectedItems, displayInfo.SelectedValues, displayInfo.SeparatorRepeatTemplate, displayInfo.SeparatorRepeat, pageInfo, EContextType.Comment, contextInfo); if (!string.IsNullOrEmpty(displayInfo.HeaderTemplate)) { pdlContents.HeaderTemplate = new SeparatorTemplate(displayInfo.HeaderTemplate); } if (!string.IsNullOrEmpty(displayInfo.FooterTemplate)) { pdlContents.FooterTemplate = new SeparatorTemplate(displayInfo.FooterTemplate); } if (!string.IsNullOrEmpty(displayInfo.SeparatorTemplate)) { pdlContents.SeparatorTemplate = new SeparatorTemplate(displayInfo.SeparatorTemplate); } if (!string.IsNullOrEmpty(displayInfo.AlternatingItemTemplate)) { pdlContents.AlternatingItemTemplate = new DataListTemplate(displayInfo.AlternatingItemTemplate, displayInfo.SelectedItems, displayInfo.SelectedValues, displayInfo.SeparatorRepeatTemplate, displayInfo.SeparatorRepeat, pageInfo, EContextType.Comment, contextInfo); } pdlContents.DataSource = objPage; pdlContents.DataBind(); if (pdlContents.Items.Count > 0) { parsedContent = ControlUtils.GetControlRenderHtml(pdlContents); } } } } } catch (Exception ex) { parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex); } //还原翻页为0,使得其他列表能够正确解析ItemIndex contextInfo.PageItemIndex = 0; return(parsedContent); }
private DataTable GetChildrenDataSet() { if (Request.QueryString["AGE"] != null) { AGE = Request.QueryString["AGE"].ToString(); } if (Request.QueryString["GENDER"] != null) { GENDER = Request.QueryString["GENDER"].ToString(); if (GENDER.ToLower() == "either") { GENDER = string.Empty; } } if (Request.QueryString["COUNTRY"] != null) { COUNTRY = Request.QueryString["COUNTRY"].ToString(); if (COUNTRY.ToLower() == "all") { COUNTRY = string.Empty; } } if (Request.QueryString["CHOOSEFORME"] != null) { CHOOSEFORME = Request.QueryString["CHOOSEFORME"].ToString(); } DataTable dt = new DataTable(); PagedDataSource page = new PagedDataSource(); page.DataSource = dt.DefaultView; page.AllowPaging = true; page.PageSize = MyContent.ResultsPerPage; page.CurrentPageIndex = this.currentPage; string age0 = string.Empty; string age1 = string.Empty; if (!string.IsNullOrEmpty(AGE)) { if (AGE.ToLower() != "all") { if (AGE.Contains("-")) { string[] range = AGE.Split('-'); age0 = range[0]; age1 = range[1]; } else { if (AGE.Substring(AGE.Length - 1, 1) == "p") { age0 = AGE.Substring(0, AGE.Length - 1); age1 = "99"; } else { age0 = AGE; age1 = AGE; } } } } //** //using(SqlConnection con = new SqlConnection(Blackbaud.Web.Content.Core.Settings.ConnectionString)) //{ // using (SqlCommand cmd = new SqlCommand("USR_USP_CHILDREN_WEBSEARCH", con)) // { // cmd.Parameters.Add(new SqlParameter("@GENDER", GENDER)); // cmd.Parameters.Add(new SqlParameter("@AGE0", age0)); // cmd.Parameters.Add(new SqlParameter("@AGE1", age1)); // cmd.Parameters.Add(new SqlParameter("@COUNTRY", COUNTRY)); // cmd.CommandType = CommandType.StoredProcedure; // using(SqlDataAdapter dta = new SqlDataAdapter(cmd)) // { // con.Open(); // dta.Fill(dt); // } // } //} //** dt.Columns.Add("ID"); dt.Columns.Add("FIRSTNAME"); dt.Columns.Add("LASTNAME"); dt.Columns.Add("FULLNAME"); dt.Columns.Add("COUNTRYNAME"); dt.Columns.Add("COUNTRYID"); dt.Columns.Add("AGE"); dt.Columns.Add("BIRTHDATE"); dt.Columns.Add("GENDER"); dt.Columns.Add("GENDERCODE"); dt.Columns.Add("PROJECTNAME"); dt.Columns.Add("PROJECTID"); dt.Columns.Add("CHILDNO"); dt.Columns.Add("ELIGIBILITY"); dt.Columns.Add("AVAILABILITY"); dt.Columns.Add("IMAGEURL"); OCM.BBISWebParts.WebsiteChurchPartnerChildSearchDataListFilterData filter = new OCM.BBISWebParts.WebsiteChurchPartnerChildSearchDataListFilterData(); filter.COUNTRY = COUNTRY; filter.GENDER = GENDER; filter.AGEMIN = age0; filter.AGEMAX = age1; //DataListLoadRequest request = Blackbaud.AppFx.Sponsorship.Catalog.WebApiClient.DataLists.Constituent.SponsorshipDataList.CreateRequest(this.API.AppFxWebServiceProvider); //request.DataListID = new Guid("5ECB50D7-01C2-4487-8B34-1ECCF6E4FF5B"); //request.ContextRecordID = MyContent.PartnerLookupID; OCM.BBISWebParts.WebsiteChurchPartnerChildSearchDataListRow[] rows = OCM.BBISWebParts.WebsiteChurchPartnerChildSearchDataList.GetRows(this.API.AppFxWebServiceProvider, MyContent.PartnerLookupID, filter); foreach (OCM.BBISWebParts.WebsiteChurchPartnerChildSearchDataListRow row in rows) { DataRow dr = dt.NewRow(); dr["ID"] = row.ID; dr["FIRSTNAME"] = row.FIRSTNAME; dr["LASTNAME"] = row.LASTNAME; dr["FULLNAME"] = row.FULLNAME; dr["COUNTRYNAME"] = row.COUNTRYNAME; dr["COUNTRYID"] = row.COUNTRYID; dr["AGE"] = row.AGE; dr["BIRTHDATE"] = row.BIRTHDATE; dr["GENDER"] = row.GENDER; dr["GENDERCODE"] = row.GENDERCODE; dr["PROJECTNAME"] = row.PROJECTNAME; dr["PROJECTID"] = row.PROJECTID; dr["CHILDNO"] = row.CHILDNO; dr["ELIGIBILITY"] = row.ELIGIBILITY; dr["AVAILABILITY"] = row.AVAILABILITY; dr["IMAGEURL"] = "custom/ChildSponsorship2/ImageHandler.ashx?context=sponsorship&type=" + MyContent.ThumbnailNoteType + "&id=" + row.ID; dt.Rows.Add(dr); } BBSession.Remove("CHILDREN"); BBSession.Add("CHILDREN", dt); return(dt); }