Exemplo n.º 1
0
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        string strWhere = this.StrWhere;
        if (this.titleAuthorSearch.Text.Trim() != "")
        {
            strWhere += " and (title like '%" + this.titleAuthorSearch.Text.Trim().Replace("'", "''")
                + "%' or author like '%" + this.titleAuthorSearch.Text.Trim().Replace("'", "''") + "%')";
        }
        if (this.isIndexShow.SelectedValue != "")
        {
            strWhere += " and isIndexShow = " + this.isIndexShow.SelectedValue;
        }

        LAnnounceBB announceBB = new LAnnounceBB();
        DataSet ds = new DataSet();

        try
        {
            ds = announceBB.GetVList(strWhere);
            DataView dv = new DataView(ds.Tables[0], "", "isIndexShow DESC,updtDt DESC", DataViewRowState.CurrentRows);
            this.grid.DataSource = dv;
            this.grid.DataBind();
            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            announceBB.Dispose();
        }
    }