protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { try { using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString())) { //Create array of Parameters List <SqlParameter> arrParm = new List <SqlParameter> { new SqlParameter("@search_name", SqlDbType.VarChar, 200) { Value = "" }, new SqlParameter("@id", SqlDbType.Int) { Value = 0 } }; conn.Open(); dsResult = SqlHelper.ExecuteDataset(conn, "sp_supplier_branch_list", arrParm.ToArray()); ViewState["dsResult"] = dsResult; } //Bind data into GridView gridView.DataSource = dsResult; gridView.FilterExpression = FilterBag.GetExpression(false); gridView.DataBind(); } catch (Exception ex) { string strErrorMsg = SPlanetUtil.LogErrorCollect(ex); ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true); } }
protected void BindGrid(bool isForceRefreshData = false) { try { if (!Page.IsPostBack || isForceRefreshData) { using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString())) { //Create array of Parameters List <SqlParameter> arrParm = new List <SqlParameter> { new SqlParameter("@user_id", SqlDbType.Int) { Value = ConstantClass.SESSION_USER_ID }, new SqlParameter("@id", SqlDbType.Int) { Value = 0 }, new SqlParameter("@search_name", SqlDbType.VarChar, 200) { Value = "" }, new SqlParameter("@service_type", SqlDbType.VarChar, 100) { Value = ConstantClass.SESSION_DEPARTMENT_SERVICE_TYPE }, // new SqlParameter("@customer_id", SqlDbType.Int) { Value = 0 }, }; conn.Open(); dsResult = SqlHelper.ExecuteDataset(conn, "sp_quotation_header_list", arrParm.ToArray()); conn.Close(); Session["SESSION_QUOTATION_LIST"] = dsResult; } } //Bind data into GridView gridView.DataSource = dsResult; gridView.FilterExpression = FilterBag.GetExpression(false); gridView.DataBind(); } catch (Exception ex) { string strErrorMsg = SPlanetUtil.LogErrorCollect(ex); ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true); } }
protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { var dsResult = new DataSet(); try { using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString())) { //Create array of Parameters List <SqlParameter> arrParm = new List <SqlParameter> { new SqlParameter("@user_id", SqlDbType.Int) { Value = ConstantClass.SESSION_USER_ID }, new SqlParameter("@id", SqlDbType.Int) { Value = 0 }, new SqlParameter("@search_name", SqlDbType.VarChar, 200) { Value = e.Parameters.ToString() } }; conn.Open(); dsResult = SqlHelper.ExecuteDataset(conn, "sp_sale_order_header_list", arrParm.ToArray()); conn.Close(); Session["SESSION_SALE_ORDER_LIST"] = dsResult; } //Bind data into GridView gridView.DataSource = dsResult; gridView.FilterExpression = FilterBag.GetExpression(false); gridView.DataBind(); } catch (Exception ex) { string strErrorMsg = SPlanetUtil.LogErrorCollect(ex); ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true); } }
protected void BindGrid(bool isForceRefreshData = false) { try { if (!Page.IsPostBack || isForceRefreshData) { string search = ""; if (Session["SEARCH"] != null) { search = Session["SEARCH"].ToString(); txtSearchBoxData.Value = search; } using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString())) { //Create array of Parameters List <SqlParameter> arrParm = new List <SqlParameter> { new SqlParameter("@search_name", SqlDbType.VarChar, 200) { Value = search }, new SqlParameter("@id", SqlDbType.Int) { Value = 0 } }; conn.Open(); dsResult = SqlHelper.ExecuteDataset(conn, "sp_supplier_list", arrParm.ToArray()); conn.Close(); /*int i = 0; * int rowId = 0; * if (Session["ROW_ID"] != null) * { * rowId = Convert.ToInt32(Session["ROW_ID"].ToString()); * // If -1, Find the most value * if (rowId == -1) * { * foreach (var row in dsResult.Tables[0].AsEnumerable()) * { * int id = Convert.ToInt32(row["id"]); * if (rowId < id) * { * rowId = id; * } * } * } * } * foreach (var row in dsResult.Tables[0].AsEnumerable()) * { * if (rowId == Convert.ToInt32(row["id"])) * { * int selectedRow = i; * int prevRow = Convert.ToInt32(Session["ROW"]); * int pageSize = gridView.SettingsPager.PageSize; * int pageIndex = (int)(selectedRow / pageSize); * int prevPageIndex = Convert.ToInt32(Session["PAGE"]); * if (prevRow == selectedRow) * { * Session["PAGE"] = prevPageIndex; * Session["ROW"] = prevPageIndex * pageSize; * } * else * { * Session["PAGE"] = pageIndex; * Session["ROW"] = selectedRow; * } * } * i++; * }*/ Session["SESSION_SUPPLIER_MASTER"] = dsResult; } } //Bind data into GridView gridView.DataSource = dsResult; gridView.FilterExpression = FilterBag.GetExpression(false); gridView.DataBind(); // Check page from session if (Session["ROW_ID"] != null) { int row = Convert.ToInt32(Session["ROW"]); gridView.FocusedRowIndex = row; } if (Session["PAGE"] != null) { int page = Convert.ToInt32(Session["PAGE"]); gridView.PageIndex = page; } if (!Page.IsPostBack && Session["COLUMN"] != null && Session["ORDER"] != null) { int order = Convert.ToInt32(Session["ORDER"]); if (order == 1) { ((GridViewDataColumn)gridView.Columns[Session["COLUMN"].ToString()]).SortAscending(); } else { ((GridViewDataColumn)gridView.Columns[Session["COLUMN"].ToString()]).SortDescending(); } } } catch (Exception ex) { string strErrorMsg = SPlanetUtil.LogErrorCollect(ex); ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true); } }