protected void ddlIsSent_SelectedIndexChanged(object sender, EventArgs e)
        {
            EntriesGV.DataSource = null;
            EntriesGV.DataBind();
            lblTotal.Text    = "0";
            CurrentPage.Text = "1";

            ShowEntries();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            appId = repo.Session_Get("uAppId");

            if (string.IsNullOrEmpty(appId))
            {
                Response.Redirect("~/UI/ErrorPage.aspx");
            }

            if (!Page.IsPostBack)
            {
                //PurgeDiv.Visible = false;
                //ExportDiv.Visible = false;
                //PurgeSel.Visible = false;
                //PagingDiv.Visible = false;
                //LoadedDiv.Visible = false;
                EntriesGV.DataSource = null;
                EntriesGV.DataBind();
                lblTotal.Text    = "0";
                CurrentPage.Text = "1";
                ShowEntries();
            }
        }
        //protected void Filter_Click(object sender, EventArgs e)
        //{
        //    //Validate Input
        //    int integer;

        //    //Needs to Test
        //    if (Int32.TryParse(CurrentPage.Text, out integer) == false)
        //    {
        //        lblModal.Text = "Please select a proper page!";
        //        ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
        //        return;
        //    }

        //    if (lblTotal.Text != "" &&
        //        (Int32.TryParse(CurrentPage.Text, out integer) == false ||
        //        Convert.ToInt32(CurrentPage.Text) < 1 ||
        //        Convert.ToInt32(CurrentPage.Text) > repo.calculateLastPage(Convert.ToInt32(lblTotal.Text), PageSize)))
        //    {
        //        lblModal.Text = "Please select a proper page!";
        //        ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
        //        return;
        //    }

        //    var Options = new Options_Models()
        //    {
        //        isSent = ddlIsSent.SelectedValue,
        //        Page = Convert.ToInt32(CurrentPage.Text),
        //        PageSize = PageSize,
        //        AppId = appId
        //    };

        //    var Result = repo.GetEntries(Options);

        //    if (!Result.Valid)
        //    {
        //        lblModal.Text = Result.message;
        //        ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
        //        return;
        //    }

        //    //json = SARepository.SerializerHelper(new Dictionary<string, object>() {
        //    //        { "Count" , Query.Count() },
        //    //        { "Entries" , retblock},
        //    //        { "EntriesHeader" , headers}
        //    //    });

        //    lblTotal.Text = Result.TotalCount.ToString();
        //    lblTotalPages.Text = repo.calculateLastPage(Convert.ToInt32(lblTotal.Text), PageSize).ToString();

        //    var dt = repo.ListOfDictionaryToDataTable(Result.DataAsDictionary);

        //    EntriesGV.DataSource = dt; // Paging?
        //    EntriesGV.DataKeyNames = Result.DataHeaders.ToArray();
        //    EntriesGV.DataBind();

        //    if (User.Identity.IsAuthenticated && User.IsInRole("Superusers"))
        //    {
        //        PurgeDiv.Visible = true;
        //        //PurgeSel.Visible = true;
        //    }
        //    else
        //    {
        //        PurgeDiv.Visible = false;
        //        PurgeSel.Visible = true;
        //    }
        //    ExportDiv.Visible = true;
        //    PagingDiv.Visible = true;
        //    LoadedDiv.Visible = true;
        //}

        protected void ShowEntries()
        {
            //Validate Input
            int integer;

            //Needs to Test
            if (Int32.TryParse(CurrentPage.Text, out integer) == false)
            {
                lblModal.Text = "Please select a proper page!";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                return;
            }

            var Options = new Options_Models()
            {
                ValidOnly = ddlValidity.SelectedValue,
                isSent    = ddlIsSent.SelectedValue,
                isPast    = radEvents.SelectedValue,
                Page      = Convert.ToInt32(CurrentPage.Text),
                PageSize  = PageSize,
                AppId     = appId
            };

            var Result = repo.GetEntries(Options);

            lblTotal.Text = Result.TotalCount.ToString();

            if (lblTotal.Text != "" &&
                (Int32.TryParse(CurrentPage.Text, out integer) == false ||
                 Convert.ToInt32(CurrentPage.Text) < 1 ||
                 Convert.ToInt32(CurrentPage.Text) > repo.calculateLastPage(Convert.ToInt32(lblTotal.Text), PageSize)))
            {
                lblModal.Text = "Please select a proper page!";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                return;
            }

            if (!Result.Valid)
            {
                //lblModal.Text = Result.message;
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                return;
            }

            //json = SARepository.SerializerHelper(new Dictionary<string, object>() {
            //        { "Count" , Query.Count() },
            //        { "Entries" , retblock},
            //        { "EntriesHeader" , headers}
            //    });


            lblTotalPages.Text = repo.calculateLastPage(Convert.ToInt32(lblTotal.Text), PageSize).ToString();

            var dt = repo.ListOfDictionaryToDataTable(Result.DataAsDictionary);

            EntriesGV.DataSource   = dt; // Paging?
            EntriesGV.DataKeyNames = Result.DataHeaders.ToArray();
            EntriesGV.DataBind();

            if (User.Identity.IsAuthenticated && User.IsInRole("Superusers"))
            {
                PurgeDiv.Visible = true;
                //PurgeSel.Visible = true;
            }
            else
            {
                PurgeDiv.Visible = false;
                PurgeSel.Visible = true;
            }
            ExportDiv.Visible = true;
            PagingDiv.Visible = true;
            LoadedDiv.Visible = true;
        }