protected void btnbindBin_Click(object sender, EventArgs e) { string condition = string.Empty; if (ddlOptionBin.SelectedIndex != 0) { if (ddlOptionBin.SelectedIndex == 1) { condition = "convert(" + ddlFieldNameBin.SelectedValue + ",System.String)='" + txtValueBin.Text.Trim() + "'"; } else if (ddlOptionBin.SelectedIndex == 2) { condition = "convert(" + ddlFieldNameBin.SelectedValue + ",System.String) like '%" + txtValueBin.Text.Trim() + "%'"; } else { condition = "convert(" + ddlFieldNameBin.SelectedValue + ",System.String) Like '" + txtValueBin.Text.Trim() + "%'"; } DataTable dtCust = (DataTable)Session["dtPBrandBin"]; DataView view = new DataView(dtCust, condition, "", DataViewRowState.CurrentRows); Session["dtInactive"] = view.ToTable(); lblTotalRecordsBin.Text = Resources.Attendance.Total_Records + " : " + view.ToTable().Rows.Count.ToString() + ""; GvCurrencyBin.DataSource = view.ToTable(); GvCurrencyBin.DataBind(); lblSelectedRecord.Text = ""; if (view.ToTable().Rows.Count == 0) { FillGridBin(); } System.Web.UI.ScriptManager.GetCurrent(this).SetFocus(txtValueBin); } }
protected void GvCurrencyBin_PageIndexChanging(object sender, GridViewPageEventArgs e) { GvCurrencyBin.PageIndex = e.NewPageIndex; DataTable dt = (DataTable)Session["dtInactive"]; GvCurrencyBin.DataSource = dt; GvCurrencyBin.DataBind(); string temp = string.Empty; for (int i = 0; i < GvCurrencyBin.Rows.Count; i++) { Label lblconid = (Label)GvCurrencyBin.Rows[i].FindControl("lblgvCurrencyId"); string[] split = lblSelectedRecord.Text.Split(','); for (int j = 0; j < lblSelectedRecord.Text.Split(',').Length; j++) { if (lblSelectedRecord.Text.Split(',')[j] != "") { if (lblconid.Text.Trim().ToString() == lblSelectedRecord.Text.Split(',')[j].Trim().ToString()) { ((CheckBox)GvCurrencyBin.Rows[i].FindControl("chkSelect")).Checked = true; } } } } }
protected void GvCurrencyBin_OnSorting(object sender, GridViewSortEventArgs e) { HDFSortbin.Value = HDFSortbin.Value == "ASC" ? "DESC" : "ASC"; DataTable dt = new DataTable(); dt = objCurr.GetCurrencyMasterInactive(); DataView dv = new DataView(dt); string Query = "" + e.SortExpression + " " + HDFSortbin.Value + ""; dv.Sort = Query; dt = dv.ToTable(); Session["dtInactive"] = dt; GvCurrencyBin.DataSource = dt; GvCurrencyBin.DataBind(); lblSelectedRecord.Text = ""; }
public void FillGridBin() { DataTable dt = new DataTable(); dt = objCurr.GetCurrencyMasterInactive(); GvCurrencyBin.DataSource = dt; GvCurrencyBin.DataBind(); Session["dtPBrandBin"] = dt; Session["dtInactive"] = dt; lblTotalRecordsBin.Text = Resources.Attendance.Total_Records + " : " + dt.Rows.Count.ToString() + ""; lblSelectedRecord.Text = ""; if (dt.Rows.Count == 0) { ImgbtnSelectAll.Visible = false; imgBtnRestore.Visible = false; } }
protected void ImgbtnSelectAll_Click(object sender, ImageClickEventArgs e) { DataTable dtPbrand = (DataTable)Session["dtInactive"]; if (ViewState["Select"] == null) { ViewState["Select"] = 1; foreach (DataRow dr in dtPbrand.Rows) { if (!lblSelectedRecord.Text.Split(',').Contains(dr["Currency_ID"])) { lblSelectedRecord.Text += dr["Currency_ID"] + ","; } } for (int i = 0; i < GvCurrencyBin.Rows.Count; i++) { string[] split = lblSelectedRecord.Text.Split(','); Label lblconid = (Label)GvCurrencyBin.Rows[i].FindControl("lblgvCurrencyId"); for (int j = 0; j < lblSelectedRecord.Text.Split(',').Length; j++) { if (lblSelectedRecord.Text.Split(',')[j] != "") { if (lblconid.Text.Trim().ToString() == lblSelectedRecord.Text.Split(',')[j].Trim().ToString()) { ((CheckBox)GvCurrencyBin.Rows[i].FindControl("chkSelect")).Checked = true; } } } } } else { lblSelectedRecord.Text = ""; DataTable dtUnit1 = (DataTable)Session["dtInactive"]; GvCurrencyBin.DataSource = dtUnit1; GvCurrencyBin.DataBind(); ViewState["Select"] = null; } }