protected void btnOk_Click(object sender, EventArgs e)
    {
        // Validate date/time (blank date/time textbox is allowed)
        if ((dtpMailout.SelectedDateTime == DateTimeHelper.ZERO_TIME) && !String.IsNullOrEmpty(dtpMailout.DateTimeTextBox.Text.Trim()))
        {
            ShowErrorInternal(GetString("newsletterissue_send.invaliddatetime"));
            return;
        }

        // Get variants (IDs) to set
        List <string> selItems = null;

        if (drpAllSelected.SelectedValue == DDLIST_SETALL)
        {
            DataSet ds = IssueInfoProvider.GetIssues(GetWhereCondition(ParentIssueID, true), null, 0, "IssueID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                selItems = new List <string>();
                int id = 0;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    id = ValidationHelper.GetInteger(dr[0], 0);
                    selItems.Add(id.ToString());
                }
            }
        }
        else if (drpAllSelected.SelectedValue == DDLIST_SETSELECTED)
        {
            selItems = grdElem.SelectedItems;
        }
        else
        {
            selItems = new List <string>();
            selItems.Add(drpAllSelected.SelectedValue);
        }

        // Check selected variants
        if ((selItems == null) || (selItems.Count <= 0))
        {
            if (drpAllSelected.SelectedValue != DDLIST_SETALL)
            {
                ShowErrorInternal(GetString("newsletterissue_send.novariantsselected"));
            }
            else
            {
                pMOut.Visible = false;
            }
            return;
        }

        DateTime       when       = (dtpMailout.SelectedDateTime == DateTimeHelper.ZERO_TIME) ? DateTime.Now : dtpMailout.SelectedDateTime;
        IssueInfo      issue      = IssueInfoProvider.GetIssueInfo(ParentIssueID);
        NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID);

        foreach (string itemId in selItems)
        {
            issue = IssueInfoProvider.GetIssueInfo(ValidationHelper.GetInteger(itemId, 0));
            if (issue == null)
            {
                continue;
            }
            TaskInfo task = IssueHelper.GetScheduledMailoutTask(issue, newsletter, false);
            if (task != null)
            {
                task.TaskNextRunTime = when;
                TaskInfoProvider.SetTaskInfo(task);
                if (issue.IssueScheduledTaskID != task.TaskID)
                {
                    issue.IssueScheduledTaskID = task.TaskID;
                    IssueInfoProvider.SetIssueInfo(issue);
                }
            }
        }

        mHighestMailoutTime = DateTime.MinValue;
        grdElem.ClearSelectedItems();
        grdElem.ReloadData();

        if (OnChanged != null)
        {
            OnChanged(this, EventArgs.Empty);
        }
    }