//protected void OnPaging(object sender, GridViewPageEventArgs e) //{ // GridView1.PageIndex = e.NewPageIndex; // GridView1.DataBind(); //} private void PopulateCheckBoxArray() { ArrayList CheckBoxArray; if (ViewState["CheckBoxArray"] != null) { CheckBoxArray = (ArrayList)ViewState["CheckBoxArray"]; } else { CheckBoxArray = new ArrayList(); } int CheckBoxIndex; bool CheckAllWasChecked = false; CheckBox chkAll = (CheckBox)GridView1.HeaderRow.Cells[0].FindControl("chkAll"); string checkAllIndex = "chkAll-" + GridView1.PageIndex; if (chkAll.Checked) { if (CheckBoxArray.IndexOf(checkAllIndex) == -1) { CheckBoxArray.Add(checkAllIndex); } } else { if (CheckBoxArray.IndexOf(checkAllIndex) != -1) { CheckBoxArray.Remove(checkAllIndex); CheckAllWasChecked = true; } } for (int i = 0; i < GridView1.Rows.Count; i++) { if (GridView1.Rows[i].RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1"); CheckBoxIndex = GridView1.PageSize * GridView1.PageIndex + (i + 1); if (chk.Checked) { if (CheckBoxArray.IndexOf(CheckBoxIndex) == -1 && !CheckAllWasChecked) { CheckBoxArray.Add(CheckBoxIndex); } } else { if (CheckBoxArray.IndexOf(CheckBoxIndex) != -1 || CheckAllWasChecked) { CheckBoxArray.Remove(CheckBoxIndex); } } } } ViewState["CheckBoxArray"] = CheckBoxArray; }
protected void Page_Load(object sender, EventArgs e) { ArrayList CheckBoxArray; if (ViewState["CheckBoxArray"] != null) { CheckBoxArray = (ArrayList)ViewState["CheckBoxArray"]; } else { CheckBoxArray = new ArrayList(); } Session.Timeout = 60; if (IsPostBack) { int CheckBoxIndex; for (int i = 0; i < GridView1.Rows.Count; i++) { if (GridView1.Rows[i].RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("chkDisable"); CheckBoxIndex = GridView1.PageSize * GridView1.PageIndex + (i + 1); if (chk.Checked) { if (CheckBoxArray.IndexOf(CheckBoxIndex) == -1) { CheckBoxArray.Add(CheckBoxIndex); } } else { if (CheckBoxArray.IndexOf(CheckBoxIndex) != -1) { CheckBoxArray.Remove(CheckBoxIndex); } } } } ViewState["CheckBoxArray"] = CheckBoxArray; } }
protected void Page_Load(object sender, EventArgs e) { #region for CheckBox ArrayList CheckBoxArray; Dictionary <int, string> qtyArray; if (ViewState["CheckBoxArray"] != null) { CheckBoxArray = (ArrayList)ViewState["CheckBoxArray"]; } else { CheckBoxArray = new ArrayList(); } if (ViewState["QtyArray"] != null) { qtyArray = (Dictionary <int, string>)ViewState["QtyArray"]; } else { qtyArray = new Dictionary <int, string>(); } #endregion #region Mendatory System.Web.UI.HtmlControls.HtmlGenericControl li = (System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("MakeOrder"); li.Attributes.Add("class", "active"); if (Session["Role"] != null) { if (Session["Role"].ToString() == "Head") { Response.Redirect("../DepartmentHead/PendingRequests.aspx"); } else if (Session["Role"].ToString() == "StoreClerk") { Response.Redirect("../StoreClerk/ViewRequesitionForm.aspx"); } else if (Session["Role"].ToString() == "StoreSupervisor") { Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx"); } else if (Session["Role"].ToString() == "StoreManager") { Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx"); } } else { Response.Redirect("../Login.aspx"); } empNo = Session["EmployeeNumber"].ToString(); Label lblWelcome = (Label)this.Master.FindControl("lblWelcome"); lblWelcome.Text = Session["Name"].ToString();//from login username #endregion cartList = RequestStationaryControler.getEmployeeCart(empNo); btnViewCart.Text = "View Cart ( " + cartList.Count + " ) "; if (IsPostBack) { #region for CheckBox int CheckBoxIndex; bool CheckAllWasChecked = false; int qtyIndex; #endregion #region Bind To Gridview for (int i = 0; i < grdItemList.Rows.Count; i++) { if (grdItemList.Rows[i].RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)grdItemList.Rows[i].Cells[5].FindControl("chkSelectItem"); TextBox qty = (TextBox)grdItemList.Rows[i].Cells[4].FindControl("txtQuantity"); CheckBoxIndex = grdItemList.PageSize * grdItemList.PageIndex + (i + 1); if (chk.Checked) { if (CheckBoxArray.IndexOf(CheckBoxIndex) == -1 && !CheckAllWasChecked) { CheckBoxArray.Add(CheckBoxIndex); qtyArray.Add(CheckBoxIndex, qty.Text); } } else { if (CheckBoxArray.IndexOf(CheckBoxIndex) != -1 || CheckAllWasChecked) { CheckBoxArray.Remove(CheckBoxIndex); qtyArray.Remove(CheckBoxIndex); } } } } #endregion } grdItemList.DataSource = RequestStationaryControler.acceptAllProducts(); grdItemList.DataBind(); ViewState["CheckBoxArray"] = CheckBoxArray; ViewState["QtyArray"] = qtyArray; }
protected void Page_Load(object sender, EventArgs e) { try { ArrayList CheckBoxArray; if (ViewState["CheckBoxArray"] != null) { CheckBoxArray = (ArrayList)ViewState["CheckBoxArray"]; } else { CheckBoxArray = new ArrayList(); } if (IsPostBack) { int CheckBoxIndex; bool CheckAllWasChecked = false; CheckBox chkAll = (CheckBox)gvAddContacts.HeaderRow.Cells[0].FindControl("checkAll"); string checkAllIndex = "chkAll-" + gvAddContacts.PageIndex; if (chkAll.Checked) { if (CheckBoxArray.IndexOf(checkAllIndex) == -1) { CheckBoxArray.Add(checkAllIndex); } } else { if (CheckBoxArray.IndexOf(checkAllIndex) != -1) { CheckBoxArray.Remove(checkAllIndex); CheckAllWasChecked = true; } } for (int i = 0; i < gvAddContacts.Rows.Count; i++) { if (gvAddContacts.Rows[i].RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)gvAddContacts.Rows[i].Cells[0].FindControl("CheckBox1"); Label lblEmpID = (Label)gvAddContacts.Rows[i].Cells[0].FindControl("lblEmpID"); CheckBoxIndex = gvAddContacts.PageSize * gvAddContacts.PageIndex + (i + 1); if (chk.Checked) { if (CheckBoxArray.IndexOf(CheckBoxIndex) == -1 && !CheckAllWasChecked) { CheckBoxArray.Add(CheckBoxIndex); if (selectid == "") { if (!selectid.Contains(lblEmpID.Text.ToString())) { selectid = lblEmpID.Text; } } else { if (!selectid.Contains(lblEmpID.Text.ToString())) { selectid = selectid + "," + lblEmpID.Text; } } } } else { if (CheckBoxArray.IndexOf(CheckBoxIndex) != -1 || CheckAllWasChecked) { CheckBoxArray.Remove(CheckBoxIndex); if (selectid.Contains("," + lblEmpID.Text.ToString())) { selectid = selectid.Replace("," + lblEmpID.Text.ToString(), ""); } else if (selectid.Contains(lblEmpID.Text.ToString() + ",")) { selectid = selectid.Replace(lblEmpID.Text.ToString() + ",", " "); } else { selectid = selectid.Replace(lblEmpID.Text.ToString(), ""); } } } } } } else if (!IsPostBack) { selectid = string.Empty; ViewState["CurrentAlphabet"] = "ALL"; this.GenerateAlphabets(); this.BindGrid(); } ViewState["CheckBoxArray"] = CheckBoxArray; } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("AddContacts.aspx:BindSecurityData() - " + ex.Message); } }