/// <summary>
    /// Handles the OnClick event of the cmdOK control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void cmdOK_OnClick(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtGroupName.Text))
        {
            DialogService.ShowMessage(GetLocalResourceObject("error_NoGroupName").ToString());
            return;
        }
        if (DialogService.DialogParameters.Count > 0)
        {
            if (DialogService.DialogParameters.ContainsKey("TargetSelectedFilterState"))
            {
                string groupId = String.Empty;
                TargetSelectedFilterState filterState = DialogService.DialogParameters["TargetSelectedFilterState"] as TargetSelectedFilterState;
                TargetsViewDataSource     ds          = new TargetsViewDataSource();
                string targetIds = null;
                ds.SelectedFilterState = filterState;
                if (lbxGroupType.SelectedValue.Equals("Contact"))
                {
                    filterState.IncludeContacts = true;
                    filterState.IncludeLeads    = false;
                }
                else
                {
                    filterState.IncludeContacts = false;
                    filterState.IncludeLeads    = true;
                }

                targetIds = ConvertToString(rdgGroupMembers.SelectedIndex == 0 ? ds.GetEntityIds(false) : ds.GetEntityIds(true));
                if (!string.IsNullOrEmpty(targetIds))
                {
                    groupId = GroupInfo.CreateAdHocGroup(targetIds, lbxGroupType.SelectedValue, txtGroupName.Text);
                }
                else
                {
                    throw new ValidationException(String.Format(GetLocalResourceObject("error_NoTargetsFound").ToString(), lbxGroupType.SelectedValue));
                }

                if (!String.IsNullOrEmpty(groupId))
                {
                    Response.Redirect(lbxGroupType.SelectedValue.Equals("Contact")
                                          ? string.Format("Contact.aspx?gid={0}", groupId)
                                          : string.Format("Lead.aspx?gid={0}", groupId));
                }
            }
            else
            {
                DialogService.ShowMessage(GetLocalResourceObject("error_NoDataSourceFound").ToString());
            }
            DialogService.CloseEventHappened(sender, e);
            Refresh();
        }
    }