Exemple #1
0
        protected void BindData(int pageindex, int parentId)
        {
            try
            {
                string where = GetAdvSearchWhereOption();

                DataTable dt            = new DataTable();
                string    allTiaoshu    = dtrowsHidden.Value.ToString();          //获取到所有的条数
                int       alltiaoshuInt = int.Parse(allTiaoshu);
                dt        = pageControl.GetList_FenYe_Common(where, pageindex, GridView1.PageSize, alltiaoshuInt, "vBudget_Department_List", "PARENTID").Tables[0];
                pageindex = pageControl.pageindex(pageindex, GridView1.PageSize, alltiaoshuInt);                //获取当前要显示的页码数【如果最后一页的最后一条记录被删除后,还能正常显示】
                if (dt.Rows.Count > 0)
                {
                    GridView1.Visible    = true;
                    GridView1.DataSource = dt;               //指定GridView1的数据是dv
                    GridView1.DataBind();                    //将上面指定的信息绑定到GridView1上
                    notice.Text = "";

                    int parentBudgetNameIndex = 5, parentBalanceIndex = 6, parentYEBalanceIndex = 7;
                    common.GroupRows(GridView1, parentBudgetNameIndex, parentBudgetNameIndex);
                    common.GroupRows(GridView1, parentBudgetNameIndex, parentBalanceIndex);
                    common.GroupRows(GridView1, parentBudgetNameIndex, parentYEBalanceIndex);

                    pageControl.SetSelectPage(pageindex, int.Parse(dtrowsHidden.Value.ToString()), DropDownList2, GridView1.PageSize, FirstPage, NextPage, PreviousPage, LastPage, Label_showInfo); //加载通用组件里面的分页函数
                    pageControlShow.Visible = true;                                                                                                                                                 //如果记录集不为空,则显示分页控件
                }
                else
                {
                    //Button_sumbit.Enabled = false;
                    //Button_modify.Enabled = false;
                    //Button_check.Enabled = false;
                    //div_total.Visible = false;
                    // Button_reset.Enabled = false;
                    GridView1.Visible = false;
                    notice.Text       = "*没有符合条件的结果!";

                    pageControlShow.Visible = false;                    //如果记录集为空,则不显示分页控件
                    if (alltiaoshuInt > 0)
                    {
                        BindData(pageindex - 1, parentId);
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
        protected void BindData(int pageIndex = 1)
        {
            try
            {
                string allTiaoshu    = dtrowsHidden.Value.ToString();             //获取到所有的条数
                int    alltiaoshuInt = int.Parse(allTiaoshu);
                string swhere        = " 1=1 ";

                if (!string.IsNullOrEmpty(txtJF.Text))
                {
                    swhere += string.Format(" and BudgetName like '%{0}%'", txtJF.Text);
                }

                DataTable dt = new DataTable();
                dt        = pageControl.GetList_FenYe_Common(swhere, pageIndex, GridView2.PageSize, alltiaoshuInt, "vBudget_Department_Statistical", "ParentId").Tables[0];
                pageIndex = pageControl.pageindex(pageIndex, GridView2.PageSize, alltiaoshuInt);                //获取当前要显示的页码数【如果最后一页的最后一条记录被删除后,还能正常显示】

                if (dt.Rows.Count > 0)
                {
                    string rowNumberCol = "PX";
                    dt.Columns.Add(rowNumberCol, typeof(string));
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i][rowNumberCol] = i + 1;
                    }

                    GridView2.Visible    = true;
                    GridView2.DataSource = dt;
                    GridView2.DataBind();
                    LB_MSG.Text = "";

                    common.GroupRows(GridView2, 10, 10);
                    common.GroupRows(GridView2, 10, 11);
                    common.GroupRows(GridView2, 10, 12);

                    pageControl.SetSelectPage(pageIndex, int.Parse(dtrowsHidden.Value.ToString()), DDL_ToPage, GridView2.PageSize, FirstPage, NextPage, PreviousPage, LastPage, Label_showInfo); //加载通用组件里面的分页函数
                    pageControlShow.Visible = true;                                                                                                                                              //如果记录集不为空,则显示分页控件
                }
            }
            catch (Exception e)
            { }
        }