/// <summary>
        /// Binds conflicts on surname while adding new client or contact.
        /// </summary>
        /// <param name="returnConflictCheck"></param>
        /// <param name="isSecondClient"></param>
        public void BindConflictCheckGridView()
        {
            try
            {
                if (returnValue.IsConflict)
                {
                    _tblConflictCheckGroup.Rows.Clear();

                    if (returnValue.Summary.Length > 0)
                    {
                        _lblConflictSurname.Text = "&nbsp;&nbsp;&nbsp;" + returnValue.Summary.ToString();
                    }

                    if (returnValue.ConflictCheckStandard.Rows.Length > 0)
                    {
                        string    selectType = "";
                        string    firstClientConflictNoteContentTemp = string.Empty;
                        bool      isNextNewGroup   = false;
                        int       NoOfConflicts    = 0;
                        TableRow  trMain           = null;
                        TableCell tcMain           = null;
                        Panel     pnlConflictCheck = null;
                        Table     tblGroup         = null;
                        Label     lblGroupHeader   = null;

                        _firstClientConflictNoteContent  = string.Empty;
                        _firstClientConflictNoteContent += Environment.NewLine;

                        // This property is for contacts.
                        _contactConflictNoteContent  = string.Empty;
                        _contactConflictNoteContent += Environment.NewLine;

                        for (int i = 0; i <= returnValue.ConflictCheckStandard.Rows.Length - 1; i++)
                        {
                            string noOfPossibleMatches = string.Empty;
                            isNextNewGroup = false;

                            if (selectType != returnValue.ConflictCheckStandard.Rows[i].SelectType)
                            {
                                NoOfConflicts = 1;

                                tcMain           = null;
                                trMain           = null;
                                tcMain           = new TableCell();
                                trMain           = new TableRow();
                                pnlConflictCheck = new Panel();
                                lblGroupHeader   = new Label();
                                tblGroup         = new Table();

                                string type_id = returnValue.ConflictCheckStandard.Rows[i].SelectType.Replace(' ', '_');

                                //Collapsible Panel
                                AjaxControlToolkit.CollapsiblePanelExtender collapsePanel = new AjaxControlToolkit.CollapsiblePanelExtender();
                                collapsePanel.ID                = "_cpe_" + type_id;
                                collapsePanel.Collapsed         = true;
                                collapsePanel.ExpandedImage     = "~/Images/GIFs/up.gif";
                                collapsePanel.CollapsedImage    = "~/Images/GIFs/down.gif";
                                collapsePanel.TargetControlID   = "_pnlConflictCheck_" + type_id;
                                collapsePanel.ExpandControlID   = "_pnlHeader_" + type_id;
                                collapsePanel.CollapseControlID = "_pnlHeader_" + type_id;
                                collapsePanel.ImageControlID    = "_img_" + type_id;
                                tcMain.Controls.Add(collapsePanel);

                                //Panel Header having Arrow Image and Label
                                Panel pnlHeader = new Panel();
                                pnlHeader.Style["Width"] = "99.9%";
                                pnlHeader.ID             = "_pnlHeader_" + type_id;
                                Image imgSelectType = new Image();
                                imgSelectType.ID = "_img_" + type_id;

                                lblGroupHeader.Style["Width"] = "80%";
                                lblGroupHeader.CssClass       = "collapseLabel";
                                lblGroupHeader.ID             = "_lblHeader" + type_id;

                                pnlHeader.Controls.Add(imgSelectType);
                                pnlHeader.Controls.Add(lblGroupHeader);
                                tcMain.Controls.Add(pnlHeader);

                                tblGroup.ID             = "_tbl_" + type_id;
                                tblGroup.CellSpacing    = 0;
                                tblGroup.Style["Width"] = "99%";

                                pnlConflictCheck.ID = "_pnlConflictCheck_" + type_id;

                                //Creating Headers
                                TableHeaderRow tblRowMatchIn = new TableHeaderRow();
                                tblRowMatchIn.CssClass = "gridViewHeader";
                                TableHeaderCell tblCellMatchIn = new TableHeaderCell();
                                tblCellMatchIn.Text            = "Match In";
                                tblCellMatchIn.Style["Width"]  = "25%";
                                tblCellMatchIn.HorizontalAlign = HorizontalAlign.Left;
                                TableHeaderCell tblCellRef = new TableHeaderCell();
                                tblCellRef.Text            = "Ref";
                                tblCellRef.Style["Width"]  = "25%";
                                tblCellRef.HorizontalAlign = HorizontalAlign.Left;
                                TableHeaderCell tblCellName = new TableHeaderCell();
                                tblCellName.Text            = "Name";
                                tblCellName.Style["Width"]  = "25%";
                                tblCellName.HorizontalAlign = HorizontalAlign.Left;
                                TableHeaderCell tblCellAddress = new TableHeaderCell();
                                tblCellAddress.Text            = "Address";
                                tblCellAddress.Style["Width"]  = "25%";
                                tblCellAddress.HorizontalAlign = HorizontalAlign.Left;

                                tblRowMatchIn.Cells.Add(tblCellMatchIn);
                                tblRowMatchIn.Cells.Add(tblCellRef);
                                tblRowMatchIn.Cells.Add(tblCellName);
                                tblRowMatchIn.Cells.Add(tblCellAddress);

                                tblGroup.Rows.Add(tblRowMatchIn);
                            }
                            else
                            {
                                NoOfConflicts += 1;
                            }

                            // Add rows for conflict check
                            TableRow tblRowConflictCheck = new TableRow();
                            tblRowConflictCheck.CssClass = "gridViewRow";

                            if ((i % 2) != 0)
                            {
                                tblRowConflictCheck.CssClass = "gridViewRowAlternate";
                            }

                            TableCell tblCellMatchInValue = new TableCell();
                            tblCellMatchInValue.Text = returnValue.ConflictCheckStandard.Rows[i].SelectType;

                            TableCell tblCellRefValue = new TableCell();
                            string    cliMatNo        = returnValue.ConflictCheckStandard.Rows[i].ClientRef.Trim();
                            if (cliMatNo.Length > 6)
                            {
                                cliMatNo = cliMatNo.Insert(6, "-");
                            }
                            tblCellRefValue.Text = cliMatNo;

                            TableCell tblCellNameValue = new TableCell();

                            if (Convert.ToBoolean(returnValue.ConflictCheckStandard.Rows[i].IsMember))
                            {
                                tblCellNameValue.Text = returnValue.ConflictCheckStandard.Rows[i].PersonTitle + " " + returnValue.ConflictCheckStandard.Rows[i].PersonName + " " + returnValue.ConflictCheckStandard.Rows[i].PersonSurName;
                            }
                            else
                            {
                                tblCellNameValue.Text = returnValue.ConflictCheckStandard.Rows[i].OrgName;
                            }
                            TableCell tblCellAddressValue = new TableCell();
                            tblCellAddressValue.Text = returnValue.ConflictCheckStandard.Rows[i].AddressStreetNo + " " + returnValue.ConflictCheckStandard.Rows[i].AddressHouseName + " " + returnValue.ConflictCheckStandard.Rows[i].AddressLine1;

                            tblRowConflictCheck.Cells.Add(tblCellMatchInValue);
                            tblRowConflictCheck.Cells.Add(tblCellRefValue);
                            tblRowConflictCheck.Cells.Add(tblCellNameValue);
                            tblRowConflictCheck.Cells.Add(tblCellAddressValue);
                            tblGroup.Rows.Add(tblRowConflictCheck);

                            if (i == returnValue.ConflictCheckStandard.Rows.Length - 1)
                            {
                                isNextNewGroup = true;
                            }
                            else if (returnValue.ConflictCheckStandard.Rows[i].SelectType != returnValue.ConflictCheckStandard.Rows[i + 1].SelectType)
                            {
                                isNextNewGroup = true;
                            }

                            if (isNextNewGroup)
                            {
                                pnlConflictCheck.Controls.Add(tblGroup);

                                lblGroupHeader.Text = "&nbsp;&nbsp;" + returnValue.ConflictCheckStandard.Rows[i].SelectType + " (" + NoOfConflicts.ToString();

                                if (NoOfConflicts == 1)
                                {
                                    lblGroupHeader.Text = lblGroupHeader.Text + " Conflict";
                                }
                                else
                                {
                                    lblGroupHeader.Text = lblGroupHeader.Text + " Conflicts";
                                }
                                lblGroupHeader.Text = lblGroupHeader.Text + ") ";

                                switch (returnValue.ConflictCheckStandard.Rows[i].SelectType)
                                {
                                case "Otherside":
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Red.Name;
                                    break;

                                case "Buyer":
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Green.Name;
                                    break;

                                case "Seller":
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Purple.Name;
                                    break;

                                case "General Contact":
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Red.Name;
                                    break;

                                case "Consolidated Sanctions":
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Orange.Name;
                                    break;

                                case "Investment Ban":
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Brown.Name;
                                    break;

                                default:
                                    lblGroupHeader.Style["Color"] = System.Drawing.Color.Black.Name;
                                    break;
                                }

                                tcMain.Controls.Add(pnlConflictCheck);
                                trMain.Cells.Add(tcMain);
                                _tblConflictCheckGroup.Rows.Add(trMain);

                                TableRow  tblRowSeparation  = new TableRow();
                                TableCell tblCellSeparation = new TableCell();
                                tblCellSeparation.CssClass = "TitleSeparation";
                                tblRowSeparation.Cells.Add(tblCellSeparation);
                                _tblConflictCheckGroup.Rows.Add(tblRowSeparation);

                                noOfPossibleMatches += NoOfConflicts.ToString() + " possible match(es) found in " + returnValue.ConflictCheckStandard.Rows[i].SelectType + " details" + Environment.NewLine;
                            }

                            selectType = returnValue.ConflictCheckStandard.Rows[i].SelectType;

                            firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].SelectType + " / ";
                            firstClientConflictNoteContentTemp += cliMatNo + " / ";

                            if (Convert.ToBoolean(returnValue.ConflictCheckStandard.Rows[i].IsMember))
                            {
                                firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].PersonTitle + " " + returnValue.ConflictCheckStandard.Rows[i].PersonName + " " + returnValue.ConflictCheckStandard.Rows[i].PersonSurName + " / ";
                            }
                            else
                            {
                                firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].OrgName + " / ";
                            }

                            firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].AddressStreetNo + " " + returnValue.ConflictCheckStandard.Rows[i].AddressHouseName + " " + returnValue.ConflictCheckStandard.Rows[i].AddressLine1 + " / ";
                            firstClientConflictNoteContentTemp += Environment.NewLine;

                            if (noOfPossibleMatches != string.Empty)
                            {
                                _firstClientConflictNoteContent = noOfPossibleMatches + firstClientConflictNoteContentTemp;

                                // Property to be used on contacts form.
                                _contactConflictNoteContent        = noOfPossibleMatches + firstClientConflictNoteContentTemp;;
                                firstClientConflictNoteContentTemp = string.Empty;
                            }
                        }
                        if (!_isSecondClient)
                        {
                            _firstClientConflictNoteContent = _lblConflictSurname.Text.Replace("&nbsp;", "") + Environment.NewLine + Environment.NewLine + _firstClientConflictNoteContent;

                            // Property to be used on contacts form.
                            _contactConflictNoteContent = _lblConflictSurname.Text.Replace("&nbsp;", "") + Environment.NewLine + Environment.NewLine + _contactConflictNoteContent;
                        }
                        else
                        {
                            _secondClientConflictNoteContent = _lblConflictSurname.Text.Replace("&nbsp;", "") + Environment.NewLine + Environment.NewLine + _firstClientConflictNoteContent;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Binds conflicts on surname while adding new client or contact.
        /// </summary>
        /// <returns></returns>
        public void BindConflictResultsGridView()
        {
            _tblConflictResultsGroup.Rows.Clear();

            if (_conflictCheckSummary.Length > 0)
            {
                _lblConflictSurname.Text = "&nbsp;&nbsp;&nbsp;" + _conflictCheckSummary.ToString();
            }

            if (_conflictCheckResults.Count > 0)
            {
                string    selectType         = string.Empty;
                string    selectTypeAsID     = string.Empty;
                bool      isNextNewGroup     = false;
                int       NoOfConflicts      = 0;
                TableRow  trMain             = null;
                TableCell tcMain             = null;
                Panel     pnlConflictResults = null;
                Table     tblGroup           = null;
                Label     lblGroupHeader     = null;

                for (int i = 0; i <= _conflictCheckResults.Count - 1; i++)
                {
                    isNextNewGroup = false;

                    if (selectType != _conflictCheckResults[i].SelectType)
                    {
                        NoOfConflicts = 1;

                        tcMain             = null;
                        trMain             = null;
                        tcMain             = new TableCell();
                        trMain             = new TableRow();
                        pnlConflictResults = new Panel();
                        lblGroupHeader     = new Label();
                        tblGroup           = new Table();
                        selectTypeAsID     = _conflictCheckResults[i].SelectType.Replace(" ", "");

                        //Collapsible Panel
                        AjaxControlToolkit.CollapsiblePanelExtender collapsePanel = new AjaxControlToolkit.CollapsiblePanelExtender();
                        collapsePanel.ID                = "_cpe_" + selectTypeAsID;
                        collapsePanel.Collapsed         = true;
                        collapsePanel.ExpandedImage     = "~/Images/GIFs/up.gif";
                        collapsePanel.CollapsedImage    = "~/Images/GIFs/down.gif";
                        collapsePanel.TargetControlID   = "_pnlConflictResults_" + selectTypeAsID;
                        collapsePanel.ExpandControlID   = "_pnlHeader_" + selectTypeAsID;
                        collapsePanel.CollapseControlID = "_pnlHeader_" + selectTypeAsID;
                        collapsePanel.ImageControlID    = "_img_" + selectTypeAsID;
                        tcMain.Controls.Add(collapsePanel);

                        //Panel Header having Arrow Image and Label
                        Panel pnlHeader = new Panel();
                        pnlHeader.Style["Width"] = "99.9%";
                        pnlHeader.ID             = "_pnlHeader_" + selectTypeAsID;
                        Image imgSelectType = new Image();
                        imgSelectType.ID = "_img_" + selectTypeAsID;

                        lblGroupHeader.Style["Width"] = "80%";
                        lblGroupHeader.CssClass       = "collapseLabel";
                        lblGroupHeader.ID             = "_lblHeader" + selectTypeAsID;

                        pnlHeader.Controls.Add(imgSelectType);
                        pnlHeader.Controls.Add(lblGroupHeader);
                        tcMain.Controls.Add(pnlHeader);

                        tblGroup.ID             = "_tbl_" + selectTypeAsID;
                        tblGroup.CellSpacing    = 0;
                        tblGroup.Style["Width"] = "99%";

                        pnlConflictResults.ID = "_pnlConflictResults_" + selectTypeAsID;

                        //Creating Headers
                        TableHeaderRow tblRowMatchIn = new TableHeaderRow();
                        tblRowMatchIn.CssClass = "gridViewHeader";
                        TableHeaderCell tblCellMatchIn = new TableHeaderCell();
                        tblCellMatchIn.Text            = "Match In";
                        tblCellMatchIn.Style["Width"]  = "25%";
                        tblCellMatchIn.HorizontalAlign = HorizontalAlign.Left;
                        TableHeaderCell tblCellRef = new TableHeaderCell();
                        tblCellRef.Text            = "Ref";
                        tblCellRef.Style["Width"]  = "25%";
                        tblCellRef.HorizontalAlign = HorizontalAlign.Left;
                        TableHeaderCell tblCellName = new TableHeaderCell();
                        tblCellName.Text            = "Name";
                        tblCellName.Style["Width"]  = "25%";
                        tblCellName.HorizontalAlign = HorizontalAlign.Left;
                        TableHeaderCell tblCellAddress = new TableHeaderCell();
                        tblCellAddress.Text            = "Address";
                        tblCellAddress.Style["Width"]  = "25%";
                        tblCellAddress.HorizontalAlign = HorizontalAlign.Left;

                        tblRowMatchIn.Cells.Add(tblCellMatchIn);
                        tblRowMatchIn.Cells.Add(tblCellRef);
                        tblRowMatchIn.Cells.Add(tblCellName);
                        tblRowMatchIn.Cells.Add(tblCellAddress);

                        tblGroup.Rows.Add(tblRowMatchIn);
                    }
                    else
                    {
                        NoOfConflicts += 1;
                    }

                    // Add rows for conflict check
                    TableRow tblRowConflictResults = new TableRow();
                    tblRowConflictResults.CssClass = "gridViewRow";

                    if ((i % 2) != 0)
                    {
                        tblRowConflictResults.CssClass = "gridViewRowAlternate";
                    }

                    TableCell tblCellMatchInValue = new TableCell();
                    tblCellMatchInValue.Text = _conflictCheckResults[i].SelectType;

                    TableCell tblCellRefValue = new TableCell();
                    tblCellRefValue.Text = this.SetClientRefText(_conflictCheckResults[i].ClientRef);

                    TableCell tblCellNameValue = new TableCell();
                    tblCellNameValue.Text = this.SetNameText(_conflictCheckResults[i].IsMember,
                                                             _conflictCheckResults[i].PersonFullName,
                                                             _conflictCheckResults[i].OrgName);

                    TableCell tblCellAddressValue = new TableCell();
                    tblCellAddressValue.Text = _conflictCheckResults[i].FullAddress;

                    tblRowConflictResults.Cells.Add(tblCellMatchInValue);
                    tblRowConflictResults.Cells.Add(tblCellRefValue);
                    tblRowConflictResults.Cells.Add(tblCellNameValue);
                    tblRowConflictResults.Cells.Add(tblCellAddressValue);
                    tblGroup.Rows.Add(tblRowConflictResults);

                    if (i == _conflictCheckResults.Count - 1)
                    {
                        isNextNewGroup = true;
                    }
                    else if (_conflictCheckResults[i].SelectType != _conflictCheckResults[i + 1].SelectType)
                    {
                        isNextNewGroup = true;
                    }

                    if (isNextNewGroup)
                    {
                        pnlConflictResults.Controls.Add(tblGroup);

                        lblGroupHeader.Text           = this.SetHeaderText(_conflictCheckResults[i].SelectType, NoOfConflicts);
                        lblGroupHeader.Style["Color"] = this.SetHeaderColour(_conflictCheckResults[i].SelectType);

                        tcMain.Controls.Add(pnlConflictResults);
                        trMain.Cells.Add(tcMain);
                        _tblConflictResultsGroup.Rows.Add(trMain);

                        TableRow  tblRowSeparation  = new TableRow();
                        TableCell tblCellSeparation = new TableCell();
                        tblCellSeparation.CssClass = "TitleSeparation";
                        tblRowSeparation.Cells.Add(tblCellSeparation);
                        _tblConflictResultsGroup.Rows.Add(tblRowSeparation);
                    }
                    selectType = _conflictCheckResults[i].SelectType;
                }
            }
            else
            {
                TableRow  tblRowSeparation  = new TableRow();
                TableCell tblCellSeparation = new TableCell();
                tblCellSeparation.CssClass = "TitleSeparation";
                tblRowSeparation.Cells.Add(tblCellSeparation);
                _tblConflictResultsGroup.Rows.Add(tblRowSeparation);

                TableRow tblRowConflictResults = new TableRow();
                tblRowConflictResults.CssClass = "gridViewRow";
                TableCell tblCellTextValue = new TableCell();
                tblCellTextValue.Text = "No matches found";
                tblRowConflictResults.Cells.Add(tblCellTextValue);
                _tblConflictResultsGroup.Rows.Add(tblRowConflictResults);

                tblRowSeparation           = new TableRow();
                tblCellSeparation          = new TableCell();
                tblCellSeparation.CssClass = "TitleSeparation";
                tblRowSeparation.Cells.Add(tblCellSeparation);
                _tblConflictResultsGroup.Rows.Add(tblRowSeparation);
            }
        }
        /// <summary>
        /// Binds conflicts on surname while adding new client or contact.
        /// </summary>
        /// <returns></returns>
        public void BindConflictResultsGridView()
        {
            _tblConflictResultsGroup.Rows.Clear();

            if (_conflictCheckSummary.Length > 0)
            {
                _lblConflictSurname.Text = "&nbsp;&nbsp;&nbsp;" + _conflictCheckSummary.ToString();
            }

            if (_conflictCheckResults.Count > 0)
            {
                string selectType = string.Empty;
                string selectTypeAsID = string.Empty;
                bool isNextNewGroup = false;
                int NoOfConflicts = 0;
                TableRow trMain = null;
                TableCell tcMain = null;
                Panel pnlConflictResults = null;
                Table tblGroup = null;
                Label lblGroupHeader = null;

                for (int i = 0; i <= _conflictCheckResults.Count - 1; i++)
                {
                    isNextNewGroup = false;

                    if (selectType != _conflictCheckResults[i].SelectType)
                    {
                        NoOfConflicts = 1;

                        tcMain = null;
                        trMain = null;
                        tcMain = new TableCell();
                        trMain = new TableRow();
                        pnlConflictResults = new Panel();
                        lblGroupHeader = new Label();
                        tblGroup = new Table();
                        selectTypeAsID = _conflictCheckResults[i].SelectType.Replace(" ", "");

                        //Collapsible Panel
                        AjaxControlToolkit.CollapsiblePanelExtender collapsePanel = new AjaxControlToolkit.CollapsiblePanelExtender();
                        collapsePanel.ID = "_cpe_" + selectTypeAsID;
                        collapsePanel.Collapsed = true;
                        collapsePanel.ExpandedImage = "~/Images/GIFs/up.gif";
                        collapsePanel.CollapsedImage = "~/Images/GIFs/down.gif";
                        collapsePanel.TargetControlID = "_pnlConflictResults_" + selectTypeAsID;
                        collapsePanel.ExpandControlID = "_pnlHeader_" + selectTypeAsID;
                        collapsePanel.CollapseControlID = "_pnlHeader_" + selectTypeAsID;
                        collapsePanel.ImageControlID = "_img_" + selectTypeAsID;
                        tcMain.Controls.Add(collapsePanel);

                        //Panel Header having Arrow Image and Label
                        Panel pnlHeader = new Panel();
                        pnlHeader.Style["Width"] = "99.9%";
                        pnlHeader.ID = "_pnlHeader_" + selectTypeAsID;
                        Image imgSelectType = new Image();
                        imgSelectType.ID = "_img_" + selectTypeAsID;

                        lblGroupHeader.Style["Width"] = "80%";
                        lblGroupHeader.CssClass = "collapseLabel";
                        lblGroupHeader.ID = "_lblHeader" + selectTypeAsID;

                        pnlHeader.Controls.Add(imgSelectType);
                        pnlHeader.Controls.Add(lblGroupHeader);
                        tcMain.Controls.Add(pnlHeader);

                        tblGroup.ID = "_tbl_" + selectTypeAsID;
                        tblGroup.CellSpacing = 0;
                        tblGroup.Style["Width"] = "99%";

                        pnlConflictResults.ID = "_pnlConflictResults_" + selectTypeAsID;

                        //Creating Headers
                        TableHeaderRow tblRowMatchIn = new TableHeaderRow();
                        tblRowMatchIn.CssClass = "gridViewHeader";
                        TableHeaderCell tblCellMatchIn = new TableHeaderCell();
                        tblCellMatchIn.Text = "Match In";
                        tblCellMatchIn.Style["Width"] = "25%";
                        tblCellMatchIn.HorizontalAlign = HorizontalAlign.Left;
                        TableHeaderCell tblCellRef = new TableHeaderCell();
                        tblCellRef.Text = "Ref";
                        tblCellRef.Style["Width"] = "25%";
                        tblCellRef.HorizontalAlign = HorizontalAlign.Left;
                        TableHeaderCell tblCellName = new TableHeaderCell();
                        tblCellName.Text = "Name";
                        tblCellName.Style["Width"] = "25%";
                        tblCellName.HorizontalAlign = HorizontalAlign.Left;
                        TableHeaderCell tblCellAddress = new TableHeaderCell();
                        tblCellAddress.Text = "Address";
                        tblCellAddress.Style["Width"] = "25%";
                        tblCellAddress.HorizontalAlign = HorizontalAlign.Left;

                        tblRowMatchIn.Cells.Add(tblCellMatchIn);
                        tblRowMatchIn.Cells.Add(tblCellRef);
                        tblRowMatchIn.Cells.Add(tblCellName);
                        tblRowMatchIn.Cells.Add(tblCellAddress);

                        tblGroup.Rows.Add(tblRowMatchIn);
                    }
                    else
                    {
                        NoOfConflicts += 1;
                    }

                    // Add rows for conflict check
                    TableRow tblRowConflictResults = new TableRow();
                    tblRowConflictResults.CssClass = "gridViewRow";

                    if ((i % 2) != 0)
                    {
                        tblRowConflictResults.CssClass = "gridViewRowAlternate";
                    }

                    TableCell tblCellMatchInValue = new TableCell();
                    tblCellMatchInValue.Text = _conflictCheckResults[i].SelectType;

                    TableCell tblCellRefValue = new TableCell();
                    tblCellRefValue.Text = this.SetClientRefText(_conflictCheckResults[i].ClientRef);

                    TableCell tblCellNameValue = new TableCell();
                    tblCellNameValue.Text = this.SetNameText(_conflictCheckResults[i].IsMember,
                        _conflictCheckResults[i].PersonFullName,
                        _conflictCheckResults[i].OrgName);

                    TableCell tblCellAddressValue = new TableCell();
                    tblCellAddressValue.Text = _conflictCheckResults[i].FullAddress;

                    tblRowConflictResults.Cells.Add(tblCellMatchInValue);
                    tblRowConflictResults.Cells.Add(tblCellRefValue);
                    tblRowConflictResults.Cells.Add(tblCellNameValue);
                    tblRowConflictResults.Cells.Add(tblCellAddressValue);
                    tblGroup.Rows.Add(tblRowConflictResults);

                    if (i == _conflictCheckResults.Count - 1)
                    {
                        isNextNewGroup = true;
                    }
                    else if (_conflictCheckResults[i].SelectType != _conflictCheckResults[i + 1].SelectType)
                    {
                        isNextNewGroup = true;
                    }

                    if (isNextNewGroup)
                    {
                        pnlConflictResults.Controls.Add(tblGroup);

                        lblGroupHeader.Text = this.SetHeaderText(_conflictCheckResults[i].SelectType, NoOfConflicts);
                        lblGroupHeader.Style["Color"] = this.SetHeaderColour(_conflictCheckResults[i].SelectType);

                        tcMain.Controls.Add(pnlConflictResults);
                        trMain.Cells.Add(tcMain);
                        _tblConflictResultsGroup.Rows.Add(trMain);

                        TableRow tblRowSeparation = new TableRow();
                        TableCell tblCellSeparation = new TableCell();
                        tblCellSeparation.CssClass = "TitleSeparation";
                        tblRowSeparation.Cells.Add(tblCellSeparation);
                        _tblConflictResultsGroup.Rows.Add(tblRowSeparation);
                    }
                    selectType = _conflictCheckResults[i].SelectType;
                }
            }
            else
            {
                TableRow tblRowSeparation = new TableRow();
                TableCell tblCellSeparation = new TableCell();
                tblCellSeparation.CssClass = "TitleSeparation";
                tblRowSeparation.Cells.Add(tblCellSeparation);
                _tblConflictResultsGroup.Rows.Add(tblRowSeparation);

                TableRow tblRowConflictResults = new TableRow();
                tblRowConflictResults.CssClass = "gridViewRow";
                TableCell tblCellTextValue = new TableCell();
                tblCellTextValue.Text = "No matches found";
                tblRowConflictResults.Cells.Add(tblCellTextValue);
                _tblConflictResultsGroup.Rows.Add(tblRowConflictResults);

                tblRowSeparation = new TableRow();
                tblCellSeparation = new TableCell();
                tblCellSeparation.CssClass = "TitleSeparation";
                tblRowSeparation.Cells.Add(tblCellSeparation);
                _tblConflictResultsGroup.Rows.Add(tblRowSeparation);
            }
        }
        /// <summary>
        /// Binds conflicts on surname while adding new client or contact.
        /// </summary>
        /// <param name="returnConflictCheck"></param>
        /// <param name="isSecondClient"></param>
        public void BindConflictCheckGridView()
        {
            try
            {
                if (returnValue.IsConflict)
                {
                    _tblConflictCheckGroup.Rows.Clear();

                    if (returnValue.Summary.Length > 0)
                    {
                        _lblConflictSurname.Text = "&nbsp;&nbsp;&nbsp;" + returnValue.Summary.ToString();
                    }

                    if (returnValue.ConflictCheckStandard.Rows.Length > 0)
                    {
                        string selectType = "";
                        string firstClientConflictNoteContentTemp = string.Empty;
                        bool isNextNewGroup = false;
                        int NoOfConflicts = 0;
                        TableRow trMain = null;
                        TableCell tcMain = null;
                        Panel pnlConflictCheck = null;
                        Table tblGroup = null;
                        Label lblGroupHeader = null;

                        _firstClientConflictNoteContent = string.Empty;
                        _firstClientConflictNoteContent += Environment.NewLine;

                        // This property is for contacts.
                        _contactConflictNoteContent = string.Empty;
                        _contactConflictNoteContent += Environment.NewLine;

                        for (int i = 0; i <= returnValue.ConflictCheckStandard.Rows.Length - 1; i++)
                        {
                            string noOfPossibleMatches = string.Empty;
                            isNextNewGroup = false;

                            if (selectType != returnValue.ConflictCheckStandard.Rows[i].SelectType)
                            {
                                NoOfConflicts = 1;

                                tcMain = null;
                                trMain = null;
                                tcMain = new TableCell();
                                trMain = new TableRow();
                                pnlConflictCheck = new Panel();
                                lblGroupHeader = new Label();
                                tblGroup = new Table();

                                string type_id = returnValue.ConflictCheckStandard.Rows[i].SelectType.Replace(' ', '_');

                                //Collapsible Panel
                                AjaxControlToolkit.CollapsiblePanelExtender collapsePanel = new AjaxControlToolkit.CollapsiblePanelExtender();
                                collapsePanel.ID = "_cpe_" + type_id;
                                collapsePanel.Collapsed = true;
                                collapsePanel.ExpandedImage = "~/Images/GIFs/up.gif";
                                collapsePanel.CollapsedImage = "~/Images/GIFs/down.gif";
                                collapsePanel.TargetControlID = "_pnlConflictCheck_" + type_id;
                                collapsePanel.ExpandControlID = "_pnlHeader_" + type_id;
                                collapsePanel.CollapseControlID = "_pnlHeader_" + type_id;
                                collapsePanel.ImageControlID = "_img_" + type_id;
                                tcMain.Controls.Add(collapsePanel);

                                //Panel Header having Arrow Image and Label
                                Panel pnlHeader = new Panel();
                                pnlHeader.Style["Width"] = "99.9%";
                                pnlHeader.ID = "_pnlHeader_" + type_id;
                                Image imgSelectType = new Image();
                                imgSelectType.ID = "_img_" + type_id;

                                lblGroupHeader.Style["Width"] = "80%";
                                lblGroupHeader.CssClass = "collapseLabel";
                                lblGroupHeader.ID = "_lblHeader" + type_id;

                                pnlHeader.Controls.Add(imgSelectType);
                                pnlHeader.Controls.Add(lblGroupHeader);
                                tcMain.Controls.Add(pnlHeader);

                                tblGroup.ID = "_tbl_" + type_id;
                                tblGroup.CellSpacing = 0;
                                tblGroup.Style["Width"] = "99%";

                                pnlConflictCheck.ID = "_pnlConflictCheck_" + type_id;

                                //Creating Headers
                                TableHeaderRow tblRowMatchIn = new TableHeaderRow();
                                tblRowMatchIn.CssClass = "gridViewHeader";
                                TableHeaderCell tblCellMatchIn = new TableHeaderCell();
                                tblCellMatchIn.Text = "Match In";
                                tblCellMatchIn.Style["Width"] = "25%";
                                tblCellMatchIn.HorizontalAlign = HorizontalAlign.Left;
                                TableHeaderCell tblCellRef = new TableHeaderCell();
                                tblCellRef.Text = "Ref";
                                tblCellRef.Style["Width"] = "25%";
                                tblCellRef.HorizontalAlign = HorizontalAlign.Left;
                                TableHeaderCell tblCellName = new TableHeaderCell();
                                tblCellName.Text = "Name";
                                tblCellName.Style["Width"] = "25%";
                                tblCellName.HorizontalAlign = HorizontalAlign.Left;
                                TableHeaderCell tblCellAddress = new TableHeaderCell();
                                tblCellAddress.Text = "Address";
                                tblCellAddress.Style["Width"] = "25%";
                                tblCellAddress.HorizontalAlign = HorizontalAlign.Left;

                                tblRowMatchIn.Cells.Add(tblCellMatchIn);
                                tblRowMatchIn.Cells.Add(tblCellRef);
                                tblRowMatchIn.Cells.Add(tblCellName);
                                tblRowMatchIn.Cells.Add(tblCellAddress);

                                tblGroup.Rows.Add(tblRowMatchIn);
                            }
                            else
                            {
                                NoOfConflicts += 1;
                            }

                            // Add rows for conflict check
                            TableRow tblRowConflictCheck = new TableRow();
                            tblRowConflictCheck.CssClass = "gridViewRow";

                            if ((i % 2) != 0)
                            {
                                tblRowConflictCheck.CssClass = "gridViewRowAlternate";
                            }

                            TableCell tblCellMatchInValue = new TableCell();
                            tblCellMatchInValue.Text = returnValue.ConflictCheckStandard.Rows[i].SelectType;

                            TableCell tblCellRefValue = new TableCell();
                            string cliMatNo = returnValue.ConflictCheckStandard.Rows[i].ClientRef.Trim();
                            if (cliMatNo.Length > 6)
                            {
                                cliMatNo = cliMatNo.Insert(6, "-");
                            }
                            tblCellRefValue.Text = cliMatNo;

                            TableCell tblCellNameValue = new TableCell();

                            if (Convert.ToBoolean(returnValue.ConflictCheckStandard.Rows[i].IsMember))
                            {
                                tblCellNameValue.Text = returnValue.ConflictCheckStandard.Rows[i].PersonTitle + " " + returnValue.ConflictCheckStandard.Rows[i].PersonName + " " + returnValue.ConflictCheckStandard.Rows[i].PersonSurName;
                            }
                            else
                            {
                                tblCellNameValue.Text = returnValue.ConflictCheckStandard.Rows[i].OrgName;
                            }
                            TableCell tblCellAddressValue = new TableCell();
                            tblCellAddressValue.Text = returnValue.ConflictCheckStandard.Rows[i].AddressStreetNo + " " + returnValue.ConflictCheckStandard.Rows[i].AddressHouseName + " " + returnValue.ConflictCheckStandard.Rows[i].AddressLine1;

                            tblRowConflictCheck.Cells.Add(tblCellMatchInValue);
                            tblRowConflictCheck.Cells.Add(tblCellRefValue);
                            tblRowConflictCheck.Cells.Add(tblCellNameValue);
                            tblRowConflictCheck.Cells.Add(tblCellAddressValue);
                            tblGroup.Rows.Add(tblRowConflictCheck);

                            if (i == returnValue.ConflictCheckStandard.Rows.Length - 1)
                            {
                                isNextNewGroup = true;
                            }
                            else if (returnValue.ConflictCheckStandard.Rows[i].SelectType != returnValue.ConflictCheckStandard.Rows[i + 1].SelectType)
                            {
                                isNextNewGroup = true;
                            }

                            if (isNextNewGroup)
                            {
                                pnlConflictCheck.Controls.Add(tblGroup);

                                lblGroupHeader.Text = "&nbsp;&nbsp;" + returnValue.ConflictCheckStandard.Rows[i].SelectType + " (" + NoOfConflicts.ToString();

                                if (NoOfConflicts == 1)
                                {
                                    lblGroupHeader.Text = lblGroupHeader.Text + " Conflict";
                                }
                                else
                                {
                                    lblGroupHeader.Text = lblGroupHeader.Text + " Conflicts";
                                }
                                lblGroupHeader.Text = lblGroupHeader.Text + ") ";

                                switch (returnValue.ConflictCheckStandard.Rows[i].SelectType)
                                {
                                    case "Otherside":
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Red.Name;
                                        break;
                                    case "Buyer":
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Green.Name;
                                        break;
                                    case "Seller":
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Purple.Name;
                                        break;
                                    case "General Contact":
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Red.Name;
                                        break;
                                    case "Consolidated Sanctions":
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Orange.Name;
                                        break;
                                    case "Investment Ban":
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Brown.Name;
                                        break;
                                    default:
                                        lblGroupHeader.Style["Color"] = System.Drawing.Color.Black.Name;
                                        break;
                                }

                                tcMain.Controls.Add(pnlConflictCheck);
                                trMain.Cells.Add(tcMain);
                                _tblConflictCheckGroup.Rows.Add(trMain);

                                TableRow tblRowSeparation = new TableRow();
                                TableCell tblCellSeparation = new TableCell();
                                tblCellSeparation.CssClass = "TitleSeparation";
                                tblRowSeparation.Cells.Add(tblCellSeparation);
                                _tblConflictCheckGroup.Rows.Add(tblRowSeparation);

                                noOfPossibleMatches += NoOfConflicts.ToString() + " possible match(es) found in " + returnValue.ConflictCheckStandard.Rows[i].SelectType + " details" + Environment.NewLine;
                            }

                            selectType = returnValue.ConflictCheckStandard.Rows[i].SelectType;

                            firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].SelectType + " / ";
                            firstClientConflictNoteContentTemp += cliMatNo + " / ";

                            if (Convert.ToBoolean(returnValue.ConflictCheckStandard.Rows[i].IsMember))
                            {
                                firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].PersonTitle + " " + returnValue.ConflictCheckStandard.Rows[i].PersonName + " " + returnValue.ConflictCheckStandard.Rows[i].PersonSurName + " / ";
                            }
                            else
                            {
                                firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].OrgName + " / ";
                            }

                            firstClientConflictNoteContentTemp += returnValue.ConflictCheckStandard.Rows[i].AddressStreetNo + " " + returnValue.ConflictCheckStandard.Rows[i].AddressHouseName + " " + returnValue.ConflictCheckStandard.Rows[i].AddressLine1 + " / ";
                            firstClientConflictNoteContentTemp += Environment.NewLine;

                            if (noOfPossibleMatches != string.Empty)
                            {
                                _firstClientConflictNoteContent = noOfPossibleMatches + firstClientConflictNoteContentTemp;

                                // Property to be used on contacts form.
                                _contactConflictNoteContent = noOfPossibleMatches + firstClientConflictNoteContentTemp; ;
                                firstClientConflictNoteContentTemp = string.Empty;
                            }
                        }
                        if (!_isSecondClient)
                        {
                            _firstClientConflictNoteContent = _lblConflictSurname.Text.Replace("&nbsp;", "") + Environment.NewLine + Environment.NewLine + _firstClientConflictNoteContent;

                            // Property to be used on contacts form.
                            _contactConflictNoteContent = _lblConflictSurname.Text.Replace("&nbsp;", "") + Environment.NewLine + Environment.NewLine + _contactConflictNoteContent;
                        }
                        else
                        {
                            _secondClientConflictNoteContent = _lblConflictSurname.Text.Replace("&nbsp;", "") + Environment.NewLine + Environment.NewLine + _firstClientConflictNoteContent;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }