public void FillGrid() { try { DataTable dt_ = new DataTable(); //dt_ = DBConnection.GetQueryData("select rtrim('[' + CAST(ProductTypeID AS VARCHAR(200)) + ']-' + ProductTypeName ) as [ProductTypeName], ProductTypeID from tbl_producttype"); dt_ = DBConnection.GetQueryData(" select stickerid,StickerName, ProDesc from tbl_Rsticker where CompanyId = '" + Session["CompanyID"] + "' and BranchId= '" + Session["BranchID"] + "'"); GVSticker.DataSource = dt_; GVSticker.DataBind(); ViewState["Sticker"] = dt_; } catch (Exception ex) { // throw; ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = ex.Message; } }
private void SearchRecord() { try { FillGrid(); DataTable _dt = (DataTable)ViewState["Sticker"]; DataView dv = new DataView(_dt, "ProductName LIKE '%" + TBSearchSticker.Text.Trim().ToUpper() + "%'", "[ProductName] ASC", DataViewRowState.CurrentRows); DataTable dt_ = new DataTable(); dt_ = dv.ToTable(); GVSticker.DataSource = dt_; GVSticker.DataBind(); ViewState["Sticker"] = dt_; } catch (Exception ex) { // throw; ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); lblalert.Text = ex.Message; } }