Exemplo n.º 1
0
        protected void dataBind()
        {
            string usertype = DropUserType.SelectedValue;
            string key=this.TextBox1.Text.Trim();
            Session["AccountsAdminKey"] = key;
            User userAdmin=new User();
            DataSet ds=new DataSet();
            if (usertype != "")
            {
                ds = userAdmin.GetUsersByType(usertype, key);
            }
            else
            {
                ds = userAdmin.GetUserList(key);
            }
            int pageIndex=this.DataGrid1.CurrentPageIndex;
            Session["AccountsAdminPage"] = pageIndex;
            DataGrid1.DataSource=ds.Tables[0].DefaultView;
            int record_Count=ds.Tables[0].Rows.Count;
            int page_Size=DataGrid1.PageSize;
            int totalPages = int.Parse(Math.Ceiling((double)record_Count/page_Size).ToString());
            if(totalPages>0)
            {
                if (pageIndex>totalPages-1)
                    pageIndex = totalPages-1;
            }
            else
            {
                pageIndex=0;
            }
            DataGrid1.CurrentPageIndex=pageIndex;
            DataGrid1.DataBind();

            //显示数量
            if (this.DataGrid1.CurrentPageIndex == 0)
            {
                btnFirst.Enabled = false;
                btnPrev.Enabled = false;
                if (this.DataGrid1.PageCount == 1)
                {
                    btnLast.Enabled = false;
                    btnNext.Enabled = false;
                }
            }
            else if (this.DataGrid1.CurrentPageIndex == this.DataGrid1.PageCount - 1)
            {
                btnLast.Enabled = false;
                btnNext.Enabled = false;
            }
            this.lblpagesum.Text = totalPages.ToString();
            this.lblpage.Text = (pageIndex + 1).ToString();
            this.lblrowscount.Text = record_Count.ToString();
        }
Exemplo n.º 2
0
 private void LoadUsers()
 {
     string usertype = "AA";
     User userAdmin = new User();
     DataSet ds = userAdmin.GetUsersByType(usertype, "");
     DropUserlist.DataSource = ds.Tables[0];
     DropUserlist.DataTextField = "UserName";
     DropUserlist.DataValueField = "UserID";
     DropUserlist.DataBind();
 }