/// <summary> /// 綁定GirdView /// </summary> /// <param name="pageIndex"></param> private void BindGrid(int pageIndex) { Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(cnKey); DataSet ds = new DataSet(); int RecordCount, PageCount; string strWhere = ViewState["strWhere"].ToString(); ds = dal.SelectTable(FormID, pageIndex, strWhere, int.Parse(ViewState["PageSize"].ToString()), ViewState["OrderField"].ToString(), out PageCount, out RecordCount); if (ViewState["CurrentPage"].ToString() == "0") ViewState["CurrentPage"] = PageCount; if (RecordCount != 0) { this.btnLast.Enabled = true; this.btnFirst.Enabled = true; this.btnToPage.Enabled = true; if (int.Parse(ViewState["CurrentPage"].ToString()) > 1) this.btnPre.Enabled = true; else this.btnPre.Enabled = false; if (int.Parse(ViewState["CurrentPage"].ToString()) < PageCount) this.btnNext.Enabled = true; else this.btnNext.Enabled = false; lblCurrentPage.Visible = true; lblCurrentPage.Text = "共 [" + RecordCount.ToString() + "] 筆記錄 第 [" + ViewState["CurrentPage"] + "] 頁 共 [" + PageCount.ToString() + "] 頁"; lblCurrentPage.Text = "Records:" + RecordCount.ToString() + " Page:" + ViewState["CurrentPage"] + "/" + PageCount.ToString(); } else { this.btnFirst.Enabled = false; this.btnPre.Enabled = false; this.btnNext.Enabled = false; this.btnLast.Enabled = false; this.btnToPage.Enabled = false; lblCurrentPage.Visible = false; } GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind(); }
/// <summary> /// 綁定GirdView /// </summary> /// <param name="pageIndex"></param> private void BindGrid(int pageIndex) { Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(cnKey); DataSet ds = new DataSet(); int RecordCount, PageCount; string strWhere = ViewState["strWhere"].ToString(); ds = dal.SelectTable(FormID, pageIndex, strWhere, int.Parse(ViewState["PageSize"].ToString()), ViewState["OrderField"].ToString(), out PageCount, out RecordCount); if (ViewState["CurrentPage"].ToString() == "0") ViewState["CurrentPage"] = PageCount; if (RecordCount != 0) { this.btnLast.Enabled = true; this.btnFirst.Enabled = true; this.btnToPage.Enabled = true; if (int.Parse(ViewState["CurrentPage"].ToString()) > 1) this.btnPre.Enabled = true; else this.btnPre.Enabled = false; if (int.Parse(ViewState["CurrentPage"].ToString()) < PageCount) this.btnNext.Enabled = true; else this.btnNext.Enabled = false; lblCurrentPage.Visible = true; lblCurrentPage.Text = "共 [" + RecordCount.ToString() + "] 筆記錄 第 [" + ViewState["CurrentPage"] + "] 頁 共 [" + PageCount.ToString() + "] 頁"; lblCurrentPage.Text = "Records:" + RecordCount.ToString() + " Page:" + ViewState["CurrentPage"] + "/" + PageCount.ToString(); } else { this.btnFirst.Enabled = false; this.btnPre.Enabled = false; this.btnNext.Enabled = false; this.btnLast.Enabled = false; this.btnToPage.Enabled = false; lblCurrentPage.Visible = false; } if (ds.Tables[0].Rows.Count > 0) { this.txtUploadDate.Text = Js.Com.PageValidate.ParseDateTime(ds.Tables[0].Rows[0]["UploadDate"].ToString()); if (ds.Tables[0].Rows[0]["State"].ToString() == "0") this.txtState.Text = Resources.Resource.CheckState0; else if (ds.Tables[0].Rows[0]["State"].ToString() == "1") this.txtState.Text = Resources.Resource.CheckState1; else if (ds.Tables[0].Rows[0]["State"].ToString() == "2") this.txtState.Text = Resources.Resource.CheckState2; else this.txtState.Text = Resources.Resource.CheckState3; } else { this.txtUploadDate.Text = ""; this.txtState.Text = ""; } GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind(); if (this.GridView1.Rows.Count > 0) { if (this.GridView1.Rows[0].Cells[14].Text.Replace(" ", "").Trim().Length > 0) { this.btnCheck.Enabled = false; this.btnUnCheck.Enabled = true; } else { this.btnCheck.Enabled = true; this.btnUnCheck.Enabled = false; } } else { this.btnCheck.Enabled = false; this.btnUnCheck.Enabled = false; } }