Exemplo n.º 1
0
        //This is the GridView of all the items in the Table
        protected override void Fill()
        {
            try {
                DataView dv = new DataView();
                if (txtSearch.Text == string.Empty)
                {
                    gvData.EmptyDataText = Message.EMPTY_LIST;
                    dv = new DataView(Redirect.Items().Tables[0]);
                }
                else
                {
                    gvData.EmptyDataText = Message.EMPTY_LIST_SEARCHED;
                    dv = new DataView(Redirect.Items(txtSearch.Text.Trim()).Tables[0]);
                }
                dv.Sort = (GridSortDirection == SortDirection.Ascending) ? GridSortExpression + " ASC" : GridSortExpression + " DESC";

                gvData.PageSize  = GridViewPageSize;
                gvData.PageIndex = PageIndex;
                ItemCount        = dv.Table.Rows.Count;

                if (SetupPager())
                {
                    tablePager.Visible = true;
                    string maxRecords = SPA.Configuration.AppSetting("MaxRecords");
                    if (ItemCount == int.Parse(maxRecords))
                    {
                        lblPagingItemsTotal.Text    = string.Format("<font color=red>{0}</font>", lblPagingItemsTotal.Text);
                        lblPagingItemsTotal.ToolTip = string.Format("Maximum record threshold of {0} encounterd! The value can be adjusted by an application administrator.", maxRecords);
                    }
                }
                else
                {
                    tablePager.Visible = false;
                }

                gvData.DataSource = dv;
                gvData.DataBind();
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }