Exemple #1
0
    //绑定数据
    private void BindData()
    {
        ZX_InfoBU info1    = new ZX_InfoBU();
        int       totalRow = 0;
        int       curpage  = 1;

        if (ViewState["curpage"] != null)
        {
            curpage = (int)ViewState["curpage"];
        }
        string orderby = null;

        if (ViewState["orderby"] != null)
        {
            orderby = ((SqlOrderBy)(ViewState["orderby"])).OrderExpression;
        }
        DataSet ds1 = new DataSet();

        if (this.DropDownList1.SelectedValue == "全部")
        {
            ds1 = info1.GetInfo("", this.titleTxt.Text, curpage, this.PageNavigator1.PageSize, orderby, out totalRow);
        }
        else
        {
            ds1 = info1.GetInfo(this.DropDownList1.SelectedValue.Trim().ToString(), this.titleTxt.Text, curpage, this.PageNavigator1.PageSize, orderby, out totalRow);
        }
        this.GridView1.DataSource = ds1;
        this.GridView1.DataBind();

        this.PageNavigator1.TotalRows   = totalRow;
        this.PageNavigator1.CurrentPage = curpage;

        if (ds1.Tables[0].Rows.Count == 0 && curpage > 1)
        {
            ViewState["curpage"] = curpage - 1;
            this.BindData();
        }

        if (totalRow == 0)
        {
            this.PageNavigator1.Visible = false;
        }

        info1.Close();
    }
Exemple #2
0
 //
 private void BindData(ZX_InfoBU info1)
 {
     this.GridView1.DataSource = info1.GetInfo("", "");
     this.GridView1.DataBind();
 }