private void PopulateGrid(string orderByColumn, BCCSortDirection sortDirection) { SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["authStore"].ConnectionString); SqlDataAdapter sqlDa = new SqlDataAdapter("select [ID], [PerfCategory], [PerfCounterName], [PerfInstance], [PollingInterval], [StatusFlag], [LastUpdate] from dbo.[bcc_PerfCounterList] where [DeleteFlag] = 'False' order by [" + orderByColumn + "] " + Enum.GetName(typeof(BCCSortDirection), sortDirection), sqlConn); DataSet ds = null; try { ds = new DataSet(); sqlDa.Fill(ds, "[bcc_PerfCounterList]"); gridPerfMon.DataSource = ds.Tables["[bcc_PerfCounterList]"].DefaultView; gridPerfMon.DataBind(); gridPerfMon.Visible = true; } catch (Exception ex) { DisplayError(ex.Message); System.Diagnostics.Debug.Write(ex.Message + ex.StackTrace, SiteMap.CurrentNode.Description); gridPerfMon.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { InitializeObjects(); if (User.IsInRole(BCCUIHelper.Constants.ROLE_ADMIN) || User.IsInRole(BCCUIHelper.Constants.ROLE_ARTIFACT)) { //if (!Page.IsPostBack) //{ PopulateGrid(sortExpression, lastDirection); ActivateGrid(); PopulateAnnoucements(); //} } else { DisplayError(BCCUIHelper.Constants.ACCESS_DENIED); } if (Page.IsPostBack) { if (Session[SiteMap.CurrentNode.Description + "SortDirection"] != null) { lastDirection = (BCCSortDirection)Session[SiteMap.CurrentNode.Description + "SortDirection"]; } else { Session[SiteMap.CurrentNode.Description + "SortDirection"] = lastDirection; } sortExpression = Session[SiteMap.CurrentNode.Description + "SortExpression"] as string; } else { Session[SiteMap.CurrentNode.Description + "SortDirection"] = lastDirection; Session[SiteMap.CurrentNode.Description + "SortExpression"] = sortExpression; } }
private void PopulateGrid(string sortExpression, BCCSortDirection direction) { try { DataTable dt = FetchPerformanceCounters(); dt.DefaultView.Sort = sortExpression + " " + direction; gridPerfCounters.DataSource = dt; gridPerfCounters.DataBind(); } catch (Exception ex) { DisplayError(ex.Message); System.Diagnostics.Debug.Write(ex.Message + ex.StackTrace, SiteMap.CurrentNode.Description); gridPerfCounters.Visible = false; } }
protected void gridPerfMon_OnSorting(object sender, GridViewSortEventArgs e) { string sortExpression2 = e.SortExpression; if (lastDirection == BCCSortDirection.ASC) { lastDirection = BCCSortDirection.DESC; } else { lastDirection = BCCSortDirection.ASC; } Session[SiteMap.CurrentNode.Description + "SortDirection"] = lastDirection; Session[SiteMap.CurrentNode.Description + "SortExpression"] = sortExpression2; PopulateGrid(sortExpression2, lastDirection); }
protected void Page_Load(object sender, EventArgs e) { InitializeObjects(); if (!(User.IsInRole(BCCUIHelper.Constants.ROLE_ADMIN) || User.IsInRole(BCCUIHelper.Constants.ROLE_ARTIFACT))) { DisplayError(BCCUIHelper.Constants.ACCESS_DENIED); } else { if (Page.IsPostBack) { lastDirection = (BCCSortDirection)ViewState[SiteMap.CurrentNode.Description + "SortDirection"]; sortExpression = ViewState[SiteMap.CurrentNode.Description + "SortExpression"] as string; } else { ViewState[SiteMap.CurrentNode.Description + "SortDirection"] = lastDirection; ViewState[SiteMap.CurrentNode.Description + "SortExpression"] = sortExpression; } } }