Example #1
0
        private void LoadList()
        {
            SO clsSO = new SO();

            string SortField = "SOID";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            if (Request.QueryString["Search"] == null)
            {
                if (Request.QueryString["status"] == null)
                {
                    PageData.DataSource = clsSO.ListAsDataTable(SOStatus.Open, SortField, sortoption).DefaultView;
                }
                else
                {
                    SOStatus status = (SOStatus)Enum.Parse(typeof(SOStatus), Common.Decrypt((string)Request.QueryString["status"], Session.SessionID));
                    PageData.DataSource = clsSO.ListAsDataTable(status, SortField, sortoption).DefaultView;
                }
            }
            else
            {
                string SearchKey = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID);
                if (Request.QueryString["status"] == null)
                {
                    PageData.DataSource = clsSO.SearchAsDataTable(SOStatus.Open, SearchKey, SortField, sortoption).DefaultView;
                }
                else
                {
                    SOStatus status = (SOStatus)Enum.Parse(typeof(SOStatus), Common.Decrypt((string)Request.QueryString["status"], Session.SessionID));
                    PageData.DataSource = clsSO.SearchAsDataTable(status, SearchKey, SortField, sortoption).DefaultView;
                }
            }

            clsSO.CommitAndDispose();

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }