protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { //TODO fields validation try { VoiceService.UpdateTheme(new VoiceTheme { VoiceThemeId = int.Parse(grid.UpdatedRow["ID"]), Name = grid.UpdatedRow["Name"], IsDefault = Convert.ToBoolean(grid.UpdatedRow["IsDefault"]), IsClose = Convert.ToBoolean(grid.UpdatedRow["IsClose"]), IsHaveNullVoice = Convert.ToBoolean(grid.UpdatedRow["IsHaveNullVoice"]) }); } catch (Exception ex) { MsgErr(ex.Message); } } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } data.Columns.Add(new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(CultureInfo.InvariantCulture); }