public void FillGrid() { try { dt_ = new DataTable(); dt_ = DBConnection.GetQueryData(" select * from users where CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'"); GVEmp.DataSource = dt_; GVEmp.DataBind(); ViewState["Emp"] = dt_; } catch (Exception ex) { //throw; ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = ex.Message; } }
protected void TBSearch_TextChanged(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); try { FillGrid(); DataTable _dt = (DataTable)ViewState["Emp"]; DataView dv = new DataView(_dt, "Username LIKE '%" + TBSearch.Text.Trim().ToUpper() + "%'", "[Username] ASC", DataViewRowState.CurrentRows); DataTable dt_ = new DataTable(); dt_ = dv.ToTable(); GVEmp.DataSource = dt_; GVEmp.DataBind(); TBSearch.Text = ""; } catch (Exception ex) { // throw; ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = ex.Message; } }