コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["theme"] == null)
        {
            Response.Redirect("Voting.aspx");
        }
        lblHead.Text = VoiceService.GetVotingName(ThemeId);
        Page.Title   = string.Format("{0} - {1} - {2}", SettingsMain.ShopName, lblHead.Text, lblSubHead.Text);

        if (!IsPostBack)
        {
            _paging = new SqlPaging
            {
                TableName    = "[Voice].[Answer]",
                ItemsPerPage = 10
            };

            _paging.AddFieldsRange(new List <Field>
            {
                new Field {
                    Name = "AnswerID as ID", IsDistinct = true
                },
                new Field {
                    Name = "Name"
                },
                new Field {
                    Name = "CountVoice"
                },
                new Field {
                    Name = "Sort", Sorting = SortDirection.Ascending
                },
                new Field {
                    Name = "IsVisible"
                },
                new Field {
                    Name = "DateAdded"
                },
                new Field {
                    Name = "DateModify"
                },
                new Field
                {
                    Name   = "FKIDTheme",
                    Filter = new EqualFieldFilter {
                        ParamName = "@Theme", Value = ThemeId.ToString()
                    }
                }
            });

            grid.ChangeHeaderImageUrl("arrowSort", "images/arrowup.gif");

            _paging.ItemsPerPage = 10;

            pageNumberer.CurrentPageIndex = 1;
            _paging.CurrentPageIndex      = 1;
            ViewState["Paging"]           = _paging;
        }
        else
        {
            _paging = (SqlPaging)(ViewState["Paging"]);
            _paging.ItemsPerPage = Convert.ToInt32(ddRowsPerPage.SelectedValue);

            if (_paging == null)
            {
                throw (new Exception("Paging lost"));
            }

            string strIds = Request.Form["SelectedIds"];

            if (!string.IsNullOrEmpty(strIds))
            {
                strIds = strIds.Trim();
                string[] arrids = strIds.Split(' ');

                _selectionFilter = new InSetFieldFilter();
                if (arrids.Contains("-1"))
                {
                    _selectionFilter.IncludeValues = false;
                    _inverseSelection = true;
                }
                else
                {
                    _selectionFilter.IncludeValues = true;
                }
                _selectionFilter.Values = arrids.Where(id => id != "-1").ToArray();
            }
        }
    }