protected override void LoadViewState(object savedState) { var myState = (object[])savedState; if (myState[0] != null) { base.LoadViewState(myState[0]); } if (myState[1] != null && myState[2] != null && myState[3] != null) { dtGlobal = (DataTable)myState[1]; var validColumns = (string[])myState[2]; var upCategory = Convert.ToString(myState[3]); var tableName = Convert.ToString(ViewState["TableName"]); var primaryKeyId = Convert.ToString(ViewState["PrimaryKey"]); var isTesting = SessionVariables.IsTesting; BindColumns(dtGlobal, tableName, primaryKeyId, HideData, isTesting, validColumns, upCategory); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); } }
private void RetrieveRecords(StringCollection sc, ActionCommand cmd) { try { ShowSelectedRecords(sc, cmd); var dt1 = new DataTable(); if (_getData != null) { dt1 = _getData(); } else { dt1 = GetGroupedRecords(); } MainGridView.DataSource = dt1; MainGridView.DataBind(); oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, dt1, MainGridView, Page); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.ManagePaging(dt1); numberedPager.Setup(dt1.Rows.Count, MainGridView); numberedPager.Changed += oGridPagiation_Changed; } catch (Exception ex) { var msg = "Deletion Error:"; msg += ex.Message; throw new Exception(msg); } }
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { //In-built paging implementation MainGridView.PageIndex = e.NewPageIndex; MainGridView.DataBind(); if (ViewState[Prefix + "CurrentPageIndex"] == null) { ViewState.Add(Prefix + "CurrentPageIndex", e.NewPageIndex); } else { ViewState[Prefix + "CurrentPageIndex"] = e.NewPageIndex; } //Synchronize with custom paging oGridPagiation = new GridPagiation(); dtGlobal = GetData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = e.NewPageIndex; oGridPagiation.ManagePaging(dtGlobal); }
private void RetrieveRecords(StringCollection sc, Command cmd) { try { ShowSelectedRecords(sc, cmd); var dt1 = new DataTable(); if (_getData != null) { dt1 = _getData(); MainGridView.DataSource = dt1; MainGridView.DataBind(); } oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dt1, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.ManagePaging(dt1); } catch (Exception ex) { string msg = "Deletion Error:"; msg += ex.Message; throw new Exception(msg); } finally { } }
private void LoadDataToGrid(bool useDefeultColumns) { using (PostgresEntities dbContext = new PostgresEntities()) { List <int> columnsIds = useDefeultColumns ? defaultVisibleColumns.ToList() : LeftMenu.GetColumnsIds(); if (columnsIds.Count == 0) { return; } // select string sql = "SELECT "; foreach (int columnId in columnsIds) { if (columnId == 0 || columnId == 1) { sql += "CAST(" + columnsNames[columnId].ToString() + " AS bigint), "; } else { sql += (columnsNames[columnId] + ", "); } } sql = sql.Substring(0, sql.Length - 2); sql += " FROM pg_stat_statements"; // where long dbId = LeftMenu.GetDbIdFilter(); if (LeftMenu.GetDbIdFilter() != -1) { sql += " WHERE dbid=" + dbId; } // order by if (GridSortDirection != null && GridSortExpression != null) { sql += " ORDER BY " + GridSortExpression + " " + GridSortDirection; } // execute var query = dbContext.Database.SqlQuery <Stat>(sql); List <Stat> items = query.Skip(MainGridView.PageSize * PageNum).Take(MainGridView.PageSize).ToList(); MainGridView.VirtualItemCount = query.Count(); MainGridView.DataSource = items; MainGridView.DataBind(); // chart ChartLabelsHiddenField.Value = ChartDataHiddenField.Value = string.Empty; foreach (Stat item in items) { ChartLabelsHiddenField.Value += item.queryid + ","; ChartDataHiddenField.Value += item.calls + ","; } ChartLabelsHiddenField.Value.Substring(0, ChartLabelsHiddenField.Value.Length - 1); ChartDataHiddenField.Value.Substring(0, ChartDataHiddenField.Value.Length - 1); } }
protected void btnUpdate_Click(object sender, EventArgs e) { var updatedData = new DataTable(); var data = new ClientDataModel(); updatedData = ClientDataManager.Search(data, SessionVariables.RequestProfile).Clone(); for (var i = 0; i < SelectedData.Rows.Count; i++) { data.ClientId = Convert.ToInt32(SelectedData.Rows[i][ClientDataModel.DataColumns.ClientId].ToString()); if (IsNameSelected) { data.Name = Name; } else { data.Name = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Name].ToString(); } if (IsDescriptionSelected) { data.Description = Description; } else { data.Description = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Description].ToString(); } if (IsSortOrderSelected) { data.SortOrder = SortOrder; } else { data.SortOrder = Convert.ToInt32(SelectedData.Rows[i][StandardDataModel.StandardDataColumns.SortOrder].ToString()); } ClientDataManager.Update(data, SessionVariables.RequestProfile); data = new ClientDataModel(); data.ClientId = Convert.ToInt32(SelectedData.Rows[i][ClientDataModel.DataColumns.ClientId].ToString()); var dt = ClientDataManager.Search(data, SessionVariables.RequestProfile); if (dt.Rows.Count == 1) { updatedData.ImportRow(dt.Rows[0]); } // if everything is done and good THEN move from thsi page. //Response.Redirect("Default.aspx?Added=" + true, false); } MainGridView.DataSource = updatedData; MainGridView.DataBind(); }
protected void drpdrpIntervalUnit_SelectedIndexChanged(object sender, EventArgs e) { var primaryKeyId = ViewState["PrimaryKey"].ToString(); dtGlobal = GetData(); Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string path = System.Web.Hosting.HostingEnvironment.MapPath("~/Scripts/Assign04.json"); //string path = @"C:\Users\sushm\Dropbox\COMP229\Comp229-Assign04\Comp229-Assign04\Scripts\Assign04.json"; string data = File.ReadAllText(path); var collection = JsonConvert.DeserializeObject <List <Json> >(data); MainGridView.DataSource = collection; MainGridView.DataBind(); }
private void LoadGridView() { DataSet ds = new DataSet(); ArrayList cle = new ArrayList(); ArrayList val = new ArrayList(); cle.Add("@ApplicationName"); val.Add("/"); ds = Cl_Fonction.Extraction_ds("aspnet_Roles_GetAllRoles", cle, val); MainGridView.DataSource = ds; MainGridView.DataBind(); }
protected void chargerGrid() { DataSet ds = new DataSet(); ArrayList cle = new ArrayList(); ArrayList val = new ArrayList(); cle.Add("@SENDER"); val.Add(0); Cl_Fonction.Extraction_ds("PS_E_SOUSMENU", cle, val); MainGridView.DataSource = ds; MainGridView.DataBind(); }
protected void chargerGrid() { DataSet ds = new DataSet(); ArrayList cle = new ArrayList(); ArrayList val = new ArrayList(); cle.Add("@Site_ID"); val.Add(user.SiteID); ds = Cl_Fonction.Extraction_ds("LISTE_JOURNALCONNECT_SITE", cle, val); MainGridView.DataSource = ds; MainGridView.DataBind(); }
protected void chargerGrid() { DataSet ds = new DataSet(); ArrayList cle = new ArrayList(); ArrayList val = new ArrayList(); cle.Add("@SENDER"); val.Add(0); ds = Cl_Fonction.Extraction_ds("PS_AFFECTATION_TYPEDOC_PROFILE", cle, val); MainGridView.DataSource = ds; MainGridView.DataBind(); }
/// <summary> /// Importeer data uit de DB in MainGridView. /// </summary> private void ImportData() { // Regenereer MainGridView MainGridView.DataSource = null; MainGridView.DataBind(); GenerateMainGridView(); // Haal DB data op if ((bool)Session["Database_FirstTime"] || (bool)Session["User_Changed"] || (bool)Session["Database_Changed"]) { RetrieveData(); Session["User_Changed"] = false; Session["Database_Changed"] = false; } // Vul dynamische lijsten GenerateDynamicLists(); // Plaats DB data in MainGridView List <Models.BU.Lecture> lectureList = (List <Models.BU.Lecture>)Session["Database_Lectures_" + UserDropdownList.SelectedValue]; if (lectureList != null) { foreach (Models.BU.Lecture lecture in (List <Models.BU.Lecture>)Session["Database_Lectures_" + UserDropdownList.SelectedValue]) { if (UserDropdownList.SelectedValue == lecture.teacher.UserID.ToString() && PeriodDropdownList.SelectedValue == lecture.period.ToString() && WeekDropdownList.SelectedValue == lecture.week.ToString()) { int[] cell = DetermineCell(lecture); string newEntry = ConstructScheduleString(lecture); MainGridView.Rows[cell[0]].Cells[cell[1]].Text = newEntry; } } } // Plaats DB data in EditGridView en LectureIdDropdownList EditGridView.DataSource = null; EditGridView.DataBind(); GenerateEditGridView(); FillEditElements(); // Plaats DB data in WishGridView WishGridView.DataSource = null; WishGridView.DataBind(); GenerateWishGridView(); // Bereken ingezette uren van docent. CalculateDeployedHours(); }
public void Setup(string tableName, GetDataDelegate getDataDelegate, GetColumnDelegate getColumnDelegate, bool pageLoad, bool isPaging) { lblHeader.Text = "Top " + tableName; if (ViewState[Prefix + "TableName"] == null) { ViewState.Add(Prefix + "TableName", tableName); } if (ViewState[Prefix + "TableName"] != null && !(ViewState[Prefix + "TableName"].ToString().Equals(tableName))) { ViewState[Prefix + "TableName"] = tableName; ViewState[Prefix + "CurrentPageIndex"] = 0; } ViewState["TableName"] = tableName; //ViewState["IsTesting"] = SessionVariables.IsTesting; ViewState["PageLoad"] = pageLoad; _getColumnDelegate = getColumnDelegate; _getData = getDataDelegate; dtGlobal = _getData(); Sample(dtGlobal, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; if (isPaging) { MainGridView.PageSize = DefaultRowCount; oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.ManagePaging(dtGlobal); } else { MainGridView.AllowPaging = isPaging; } MainGridView.DataBind(); }
protected override void LoadViewState(object savedState) { var myState = (object[])savedState; if (myState[0] != null) { base.LoadViewState(myState[0]); } if (myState[1] != null) { dtGlobal = (DataTable)myState[1]; MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); } }
/// <summary> /// Genereer Columns en Rows voor MainGridView. /// </summary> private void GenerateMainGridView() { // DataTable voor tijdelijke opslag Columns en Rows DataTable dataTable = new DataTable(); // Maak Columns als deze er niet zijn if (MainGridView.Columns.Count == 0) { dataTable.Columns.Add("Tijd", typeof(string)); dataTable.Columns.Add("Maandag", typeof(string)); dataTable.Columns.Add("Dinsdag", typeof(string)); dataTable.Columns.Add("Woensdag", typeof(string)); dataTable.Columns.Add("Donderdag", typeof(string)); dataTable.Columns.Add("Vrijdag", typeof(string)); } // Maak Rows als deze er niet zijn if (MainGridView.Rows.Count == 0) { int minHour = 9; // vroegste tijd = 09:00 int maxHour = 18; // laatste tijd = 18:00 int currentHour = minHour; // huidige uur om te plaatsen bool halfHour = false; // plaats een half uur? for (int t = 0; t <= maxHour; t++) { // DataRow voor een tijdelijke Row om in de DataTable te plaatsen DataRow dataRow = dataTable.NewRow(); if (halfHour) { dataRow["Tijd"] = currentHour + ":30"; currentHour++; } else { dataRow["Tijd"] = currentHour + ":00"; } halfHour = !halfHour; dataTable.Rows.Add(dataRow); } } // Voeg Columns en Rows toe aan de MainGridView MainGridView.DataSource = dataTable; MainGridView.DataBind(); }
//This method is used for databinding the gridview to a dataSet from the BookWormService private void DataBindGridView() { //Declare the FilterAlgoithm class and use the filter method FilterAlgorithm filterSearch = new FilterAlgorithm(); //Remove ' to prevent sqlinjection/Exeption querystring = filterSearch.Filter(SearchTxtb.Text.Replace("'", ""), DdlGenre.Text, OrderByPreDdl.Text, OrderBySufDdl.Text); //Open a new instance of the bookWormService Service BookWormService = new Service(); //Execute the structed query MainGridView.DataSource = BookWormService.ExecuteQuery(querystring); //Databind MainGridView.DataBind(); //Dispose the resources BookWormService.Dispose(); }
protected void lnkfontlarger_Click(object sender, EventArgs e) { //griddiv.Style.Add("font-size", "16px"); //MainGridView.CssClass = "largerfontgrid"; MainGridView.DataBind(); oGridPagiation = new GridPagiation(); dtGlobal = _getData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.ManagePaging(dtGlobal); if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); } //MainGridView.CssClass = "largerfontgrid"; }
protected void txtInterval_TextChanged(object sender, EventArgs e) { //plcPaging.Controls.Clear(); //ViewState["AuditHistoryAdvancedModeInterval"] var _pagesize = 0; if (int.TryParse(txtInterval.Text, out _pagesize)) { SessionVariables.AuditHistoryAdvancedModeInterval = txtInterval.Text; } dtGlobal = GetData(); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); }
public void SetUp(string[] columns, string tableName, DataTable data) { Data = data; GridColumns = columns; EntityName = tableName; MainGridView.DataSource = data; MainGridView.DataBind(); if (Session["CUDataObject"] == null) { Session.Add("CUDataObject", data); } else { Session["CUDataObject"] = data; } }
protected void drpAdvancedModeGrouping_SelectedIndexChanged(object sender, EventArgs e) { //if (drpGridViewMode.SelectedValue == "classic") //{ // this.ViewMode = GridViewMode.Classic; // dynAdvancedMode.Visible = true; //} //else //{ // txtInterval.Text = Convert.ToString(ApplicationCommon.GetAuditHistoryAdvancedModeInterval()); // dynAdvancedMode.Visible = true; // this.ViewMode = GridViewMode.Advanced; //} if (drpAdvancedModeGrouping.SelectedValue == "timeinterval") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.TimeInterval; if (string.IsNullOrEmpty(txtInterval.Text)) { txtInterval.Text = Convert.ToString(ConvertTimeIntervalInMinute(PerferenceUtility.GetUserPreferenceByKeyAsInt(ApplicationCommon.HistoryAdvancedModeIntervalKey))); } dynIntervalMode.Visible = true; } else { dynIntervalMode.Visible = false; if (drpAdvancedModeGrouping.SelectedValue == "auditaction") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.AuditAction; } else { AdvancedModeGrouping = GridViewAdvancedModeGrouping.ActionByAndAuditAction; } } var primaryKeyId = ViewState["PrimaryKey"].ToString(); dtGlobal = GetData(); Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //Check the cookies to see if the user is loggedin otherwise redirect to Register.aspx if (Request.Cookies["LoggedInCookie"] == null || (Request.Cookies["LoggedInCookie"] != null && Request.Cookies["LoggedInCookie"]["LoggedIn"] != "true")) { Response.Redirect("Register.aspx"); } //Check if the page has been loaded before if (!Page.IsPostBack) { //Add mouseenter/mouseover events to the image buttons FindYesBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/YesMouseOver.jpg'"); FindYesBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/YesDefault.jpg'"); FindNoBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/NoMouseOver.jpg'"); FindNoBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/NoDefault.jpg'"); //Databind items to the DropDownList (DdlGenere) using an ArrayCollection //Used to databind the dropdownlist with the book genres ArrayList DdlGenreArray = new ArrayList(); //DataBind the dropdownlist by getting the list from the ArrayCollections class ArrayCollections getlist = new ArrayCollections(); //Get the list DdlGenreArray = getlist.GenreList(); //Apply the source DdlGenre.DataSource = DdlGenreArray; //DataBind DdlGenre.DataBind(); //Open a new instance of the bookWormService Service BookWormService = new Service(); //Execute the query against the database on the service (Man, I love APIs) MainGridView.DataSource = BookWormService.ExecuteQuery("SELECT [BookId], [BookName], [BookImageUrl], [BookAuthor], [BookAverageRating] FROM [BookInformation] "); //Databind the gridView MainGridView.DataBind(); //Dispose of the Service Resources BookWormService.Dispose(); } }
protected void drpGridViewMode_SelectedIndexChanged(object sender, EventArgs e) { if (drpGridViewMode.SelectedValue == "classic") { ViewMode = GridViewMode.Classic; dynAdvancedMode.Visible = false; } else { txtInterval.Text = PerferenceUtility.GetUserPreferenceByKey(ApplicationCommon.HistoryAdvancedModeIntervalKey); dynAdvancedMode.Visible = true; ViewMode = GridViewMode.Advanced; } var primaryKeyId = ViewState["PrimaryKey"].ToString(); dtGlobal = GetData(); Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); }
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { //In-built paging implementation MainGridView.PageIndex = e.NewPageIndex; MainGridView.DataBind(); CurrentPageIndex = e.NewPageIndex; //Synchronize with custom paging oGridPagiation = new GridPagiation(); dtGlobal = _getData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = e.NewPageIndex; oGridPagiation.ManagePaging(dtGlobal); if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); } }
private void RefreshGrid() { if (CurrentPageIndex != null) { MainGridView.PageIndex = CurrentPageIndex.Value; } else { MainGridView.PageIndex = 0; } MainGridView.DataBind(); oGridPagiation = new GridPagiation(); dtGlobal = _getData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = MainGridView.PageIndex; oGridPagiation.ManagePaging(dtGlobal); if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); } }
private void RefreshGrid() { if (ViewState[Prefix + "CurrentPageIndex"] != null) { MainGridView.PageIndex = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } else { MainGridView.PageIndex = 0; } MainGridView.DataBind(); oGridPagiation = new GridPagiation(); dtGlobal = GetData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = MainGridView.PageIndex; oGridPagiation.ManagePaging(dtGlobal); if (ViewState[Prefix + "SortExpression"] != null && ViewState[Prefix + "SortDirection"] != null) { SortGridView(ViewState[Prefix + "SortExpression"].ToString(), ViewState[Prefix + "SortDirection"].ToString()); } }
private DataTable SortGridView(string sortExpression, string sortDirection) { var tableFolder = ViewState["TableFolder"].ToString(); var tableName = ViewState["TableName"].ToString(); var primaryKeyId = ViewState["PrimaryKey"].ToString(); //var isTesting = (bool)(ViewState["IsTesting"]); var currentpage = MainGridView.PageIndex; var currentpagesize = MainGridView.PageSize; var totalnumofrows = MainGridView.Rows.Count; var dtlocal = new DataTable(); var sortedtable = new DataTable(); var dtlocal2 = new DataTable(); var floor = (currentpage * currentpagesize); var ceil = ((currentpage * currentpagesize) + currentpagesize) - 1; if (ceil > dtGlobal.Rows.Count) { ceil = dtGlobal.Rows.Count - 1; } if (ViewState["SessionUpdated"] != null) { dtGlobal = GetData(); } else { dtGlobal = GetDataSet(tableName); } //Extract Sort Info from Session if (ViewState[Prefix + "SortExpression"] != null) { if (dtGlobal.Columns.Contains(ViewState[Prefix + "SortExpression"].ToString())) { sortExpression = ViewState[Prefix + "SortExpression"].ToString(); } } if (ViewState[Prefix + "SortDirection"] != null) { sortDirection = ViewState[Prefix + "SortDirection"].ToString(); } else { if (sortDirection.Equals("Ascending")) { sortDirection = "ASC"; } else { sortDirection = "DESC"; } } var columns = new string[dtGlobal.Columns.Count]; var coltypes = new Type[dtGlobal.Columns.Count]; var cnt = 0; //create Data Table objects foreach (DataColumn column in dtGlobal.Columns) { columns[cnt] = column.ColumnName; coltypes[cnt] = column.GetType(); cnt++; } dtlocal.Clear(); dtlocal.Reset(); for (var i = 0; i < columns.Length; i++) { var dc = new DataColumn(columns[i], typeof(string)); sortedtable.Columns.Add(dc); var dc2 = new DataColumn(columns[i], typeof(string)); dtlocal.Columns.Add(dc2); var dc3 = new DataColumn(columns[i], typeof(string)); dtlocal2.Columns.Add(dc3); } //Load dtlocal with current rows in view for (var i = floor; i <= ceil; i++) { if (dtGlobal.Rows.Count >= ceil && i < dtGlobal.Rows.Count) { dtlocal.ImportRow(dtGlobal.Rows[i]); } } //sort current rows in view if (!string.IsNullOrEmpty(sortExpression)) { dtlocal2 = SortDataTable(dtlocal, sortExpression, sortDirection); } //rebuild the datatable with sorted rows in view and rest of the rows for (var i = 0; i < dtGlobal.Rows.Count; i++) { if (i == floor) { for (var j = 0; j <= dtlocal2.Rows.Count - 1; j++) { if (dtlocal2.Rows[j] != null) { sortedtable.ImportRow(dtlocal2.Rows[j]); } else { sortedtable.ImportRow(dtGlobal.Rows[j]); } } i = ceil + 1; } if (i < dtGlobal.Rows.Count) { sortedtable.ImportRow(dtGlobal.Rows[i]); } } // fix this name .. Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); var dv = dtGlobal.DefaultView; // if blank, only should really be the first time // then we don't want to appened the sort instruction if (!string.IsNullOrEmpty(sortExpression) && dtGlobal.Columns.Contains(sortExpression)) { dv.Sort = sortExpression + " " + sortDirection; //System.Diagnostics.Debug.WriteLine(dv.Sort); } //Bind data based on the sort selection if (!skipgridreload) { //if (RadioButtonList1.SelectedItem.Value.Equals("FTSort")) //{ MainGridView.DataSource = dv; MainGridView.DataBind(); //} //else //{ // MainGridView.DataSource = sortedtable; // MainGridView.DataBind(); //} if (MainGridView.AllowPaging) { if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.RefreshGrid = false; oGridPagiation.ManagePaging(dtGlobal); } } //if (RadioButtonList1.SelectedItem.Value.Equals("FTSort")) //{ return(dv.ToTable(ViewState["TableName"].ToString())); //} //else //{ // return sortedtable; //} }
protected void chkSelectAll_CheckedChanged(object sender, EventArgs e) { int currentpage = MainGridView.PageIndex; int currentpagesize = MainGridView.PageSize; int totalnumofrows = MainGridView.Rows.Count; var floor = (currentpage * currentpagesize); var ceil = ((currentpage * currentpagesize) + currentpagesize) - 1; StringCollection sc = new StringCollection(); string id = String.Empty; DataTable dt1 = new DataTable(); CheckBox selectall = (CheckBox)MainGridView.HeaderRow.Cells[0].FindControl("chkSelectAll"); bool chkchecked = selectall.Checked; if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { skipgridreload = true; dt1 = SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); skipgridreload = false; } else { dt1 = dtGlobal; } MainGridView.DataSource = dt1; MainGridView.DataBind(); oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dt1, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.ManagePaging(dt1); selectall = (CheckBox)MainGridView.HeaderRow.Cells[0].FindControl("chkSelectAll"); selectall.Checked = chkchecked; //loop the GridView Rows int j = 0; for (var i = floor; i <= ceil; i++) { if (j < MainGridView.Rows.Count) { CheckBox cb = (CheckBox)MainGridView.Rows[j].Cells[0].FindControl("CheckBox1"); //find the CheckBox if (cb != null && selectall != null) { if (selectall.Checked) { if (!cb.Checked) { cb.Checked = true; // add the id to be deleted in the StringCollection } } else { if (cb.Checked) { cb.Checked = false; } } } j++; } } }
public void Setup(int systemEntityId, int entityKey, string UserPreferenceCategory = "") { var tableName = "AuditHistory"; var primaryKey = "AuditHistoryId"; var isPaging = true; SystemEntityTypeId = systemEntityId; EntityKey = entityKey; Prefix = entityKey.ToString(); var userPreferenceCategory = UserPreferenceCategory; if (string.IsNullOrEmpty(userPreferenceCategory)) { userPreferenceCategory = tableName; } SetViewState(); var userGrouping = PerferenceUtility.GetUserPreferenceByKey(ApplicationCommon.HistoryAdvancedModeGroupingKey, userPreferenceCategory); if (userGrouping == "timeinterval") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.TimeInterval; txtInterval.Text = Convert.ToString(ConvertTimeIntervalInMinute(PerferenceUtility.GetUserPreferenceByKeyAsInt(ApplicationCommon.HistoryAdvancedModeIntervalKey))); drpAdvancedModeGrouping.SelectedValue = "timeinterval"; dynIntervalMode.Visible = true; } else { dynIntervalMode.Visible = false; if (userGrouping == "auditaction") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.AuditAction; drpAdvancedModeGrouping.SelectedValue = "auditaction"; } else if (userGrouping == "actionby") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.ActionByAndAuditAction; drpAdvancedModeGrouping.SelectedValue = "actionby"; } } dtGlobal = GetData(); Sample(dtGlobal, primaryKey, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; if (isPaging) { MainGridView.PageSize = SessionVariables.DefaultRowCount; oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.ManagePaging(dtGlobal); } else { MainGridView.AllowPaging = isPaging; } MainGridView.DataBind(); }
public void Setup( string tableName, string tableFolder, string primaryKey, bool pageLoad , GetDataDelegate getDataDelegate, GetColumnDelegate getColumnDelegate , bool isPaging, int entityKey, string UserPreferenceCategory = "") { EntityKey = entityKey; Prefix = entityKey.ToString(); _getData = getDataDelegate; _getColumnDelegate = getColumnDelegate; ViewState["TableFolder"] = tableFolder; ViewState["TableName"] = tableName; var userPreferenceCategory = UserPreferenceCategory; if (string.IsNullOrEmpty(userPreferenceCategory)) { userPreferenceCategory = tableName; } if (ViewState[Prefix + "TableName"] == null) { ViewState.Add(Prefix + "TableName", tableName); } if (ViewState[Prefix + "TableName"] != null && !(ViewState[Prefix + "TableName"].ToString().Equals(tableName))) { ViewState[Prefix + "TableName"] = tableName; ViewState[Prefix + "CurrentPageIndex"] = 0; } ViewState["TableName"] = tableName; ViewState["PrimaryKey"] = primaryKey; //ViewState["IsTesting"] = SessionVariables.IsTesting; ViewState["PageLoad"] = pageLoad; dtGlobal = GetData(); Sample(dtGlobal, primaryKey, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; if (isPaging) { MainGridView.PageSize = DefaultRowCount; oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.ManagePaging(dtGlobal); } else { MainGridView.AllowPaging = isPaging; } MainGridView.DataBind(); }