private object GridVariants_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        if (sourceName.Equals("variantName", StringComparison.OrdinalIgnoreCase))
        {
            var drv   = UniGridFunctions.GetDataRowView(sender as DataControlFieldCell);
            var issue = new IssueInfo(drv.Row);

            string navigateUrl = EmailBuilderHelper.GetNavigationUrl(Issue.IssueNewsletterID, issue.IssueID, 2);

            return(new HyperLink
            {
                NavigateUrl = navigateUrl,
                Text = HTMLHelper.HTMLEncode(issue.GetVariantName())
            });
        }

        if (sourceName.Equals("delete", StringComparison.OrdinalIgnoreCase))
        {
            var dr           = UniGridFunctions.GetDataRowView(parameter);
            int issueId      = Convert.ToInt32(dr["IssueID"]);
            var deleteButton = (CMSGridActionButton)sender;
            deleteButton.Enabled = (OriginalVariant.IssueID != issueId) && Enabled;
        }

        return(parameter);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle.TitleText            = GetString("newsletter_winnermailout.title");
        PageTitle.ShowFullScreenButton = false;

        RegisterModalPageScripts();
        RegisterEscScript();
        // Register script for refreshing parent page
        ScriptHelper.RegisterStartupScript(Page, GetType(), "RefreshParent", "function RefreshPage() {if((wopener)&&(wopener.RefreshPage!=null)){wopener.RefreshPage();}}", true);

        btnSend.Click += btnSend_Click;

        // Show variant name in info message
        string    variantName = GetString("general.na");
        IssueInfo winner      = (IssueInfo)EditedObject;

        if (winner != null)
        {
            // Prevent accessing issues from sites other than current site
            if (winner.IssueSiteID != SiteContext.CurrentSiteID)
            {
                RedirectToResourceNotAvailableOnSite("Issue with ID " + winner.IssueID);
            }

            variantName = HTMLHelper.HTMLEncode(winner.GetVariantName());
        }
        lblInfo.Text = String.Format(GetString("newsletter_winnermailout.question"), variantName);
    }
    private object GetIssueVariantName(DataRowView rowView)
    {
        var issue  = new IssueInfo(rowView.Row);
        var result = issue.GetVariantName();

        // Issue has not been sent yet => get mail out time from scheduled task
        if (issue.IssueID == WinnerIssueID)
        {
            result += " " + GetString("newsletterabtest.winner");
        }

        return(HTMLHelper.HTMLEncode(result));
    }
    protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName)
        {
        case "variantname":
            if (!isMainABTestIssue)
            {
                return(null);
            }

            IssueInfo issue       = IssueInfoProvider.GetIssueInfo(ValidationHelper.GetInteger(parameter, 0));
            string    variantName = null;

            if (issue != null)
            {
                if (!issue.IssueIsVariant)
                {
                    // Get variant name from the winner issue
                    if (winnerIssue == null)
                    {
                        ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID);
                        if (test != null)
                        {
                            // Get A/B test winner variant
                            winnerIssue = IssueInfoProvider.GetIssueInfo(test.TestWinnerIssueID);
                        }
                    }

                    if (winnerIssue != null)
                    {
                        // Get variant name
                        variantName = winnerIssue.GetVariantName();
                    }
                }
                else
                {
                    // Get variant name
                    variantName = issue.GetVariantName();
                }
            }

            return(HTMLHelper.HTMLEncode(variantName));

        default:
            return(parameter);
        }
    }