Пример #1
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (grid.UpdatedRow != null)
        {
            try
            {
                int countVoices = 0;
                int sort        = 0;
                if (Int32.TryParse(grid.UpdatedRow["CountVoice"], out countVoices) && Int32.TryParse(grid.UpdatedRow["Sort"], out sort))
                {
                    var answer = new Answer
                    {
                        AnswerId   = Convert.ToInt32(grid.UpdatedRow["ID"]),
                        Name       = grid.UpdatedRow["Name"],
                        IsVisible  = Convert.ToBoolean(grid.UpdatedRow["IsVisible"]),
                        FkidTheme  = ThemeId,
                        CountVoice = countVoices,
                        Sort       = sort
                    };
                    VoiceService.UpdateAnswer(answer);
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
        }

        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();
    }