/// <summary>
        /// Creates the table controls.
        /// </summary>
        private void BindHtmlGrid()
        {
            _financialTransactionDetailList = null;
            RockContext rockContext = new RockContext();

            List <DataControlField> tableColumns = new List <DataControlField>();

            tableColumns.Add(new RockLiteralField {
                ID = "lPerson", HeaderText = "Person"
            });
            tableColumns.Add(new RockLiteralField {
                ID = "lTransactionInfo", HeaderText = "Transaction Info"
            });
            tableColumns.Add(new RockLiteralField {
                ID = "lCheckImage", HeaderText = "Check Image"
            });
            tableColumns.Add(new RockLiteralField {
                ID = "lMatchedRegistration", HeaderText = "Matched Registration"
            });
            tableColumns.Add(new RockLiteralField {
                ID = "lButton"
            });

            StringBuilder headers = new StringBuilder();

            foreach (var tableColumn in tableColumns)
            {
                if (tableColumn.HeaderStyle.CssClass.IsNotNullOrWhiteSpace())
                {
                    headers.AppendFormat("<th class='{0}'>{1}</th>", tableColumn.HeaderStyle.CssClass, tableColumn.HeaderText);
                }
                else
                {
                    headers.AppendFormat("<th>{0}</th>", tableColumn.HeaderText);
                }
            }

            lHeaderHtml.Text = headers.ToString();
            var registrationEntityTypeId = EntityTypeCache.GetId <Registration>();

            if (BatchId.HasValue && RegistrationInstanceId.HasValue)
            {
                nbErrorMessage.Visible = false;
                try
                {
                    var financialTransactionDetailQuery = new FinancialTransactionDetailService(rockContext).Queryable()
                                                          .Include(a => a.Transaction)
                                                          .Include(a => a.Transaction.AuthorizedPersonAlias.Person)
                                                          .Where(a => a.Transaction.BatchId == BatchId.Value && (!a.EntityTypeId.HasValue || a.EntityTypeId == registrationEntityTypeId))
                                                          .OrderByDescending(a => a.Transaction.TransactionDateTime);

                    _financialTransactionDetailList = financialTransactionDetailQuery.Take(1000).ToList();
                }
                catch (Exception ex)
                {
                    ExceptionLogService.LogException(ex);
                    var sqlTimeoutException = ReportingHelper.FindSqlTimeoutException(ex);

                    if (sqlTimeoutException != null)
                    {
                        nbErrorMessage.NotificationBoxType = NotificationBoxType.Warning;
                        nbErrorMessage.Text = "This report did not complete in a timely manner. You can try again or adjust the timeout setting of this block.";
                    }
                    else
                    {
                        nbErrorMessage.Text = "There was a problem with one of the filters for this report's dataview.";
                        nbErrorMessage.NotificationBoxType = NotificationBoxType.Danger;
                        nbErrorMessage.Details             = ex.Message;
                        nbErrorMessage.Visible             = true;
                        return;
                    }
                }

                phTableRows.Controls.Clear();

                int rowCount = 0;
                foreach (var financialTransactionDetail in _financialTransactionDetailList)
                {
                    rowCount += 1;
                    var tr = new HtmlGenericContainer("tr");
                    tr.ID = "tr_" + rowCount;
                    foreach (var tableColumn in tableColumns)
                    {
                        var literalControl = new LiteralControl();
                        if (tableColumn is RockLiteralField)
                        {
                            tr.Controls.Add(literalControl);
                            var literalTableColumn = tableColumn as RockLiteralField;
                            if (literalTableColumn.ID == "lPerson")
                            {
                                literalControl.Text = string.Format("<td>{0}</td>", financialTransactionDetail.Transaction.AuthorizedPersonAlias);
                            }
                            else if (literalTableColumn.ID == "lTransactionInfo")
                            {
                                literalControl.Text = string.Format("<td>{0}<br/>{1}</td>", financialTransactionDetail.Amount.FormatAsCurrency(), financialTransactionDetail.Account.ToString());
                            }
                            else if (literalTableColumn.ID == "lCheckImage")
                            {
                                var primaryImage = financialTransactionDetail.Transaction.Images
                                                   .OrderBy(i => i.Order)
                                                   .FirstOrDefault();
                                string imageTag = string.Empty;
                                if (primaryImage != null)
                                {
                                    var imageUrl = string.Format("~/GetImage.ashx?id={0}", primaryImage.BinaryFileId);
                                    imageTag = string.Format("<div class='photo transaction-image' style='max-width: 400px;'><a href='{0}'><img src='{0}'/></a></div>", ResolveRockUrl(imageUrl));
                                }

                                literalControl.Text = string.Format("<td>{0}</td>", imageTag);
                            }
                            else if (literalTableColumn.ID == "lTransactionType")
                            {
                                literalControl.ID   = "lTransactionType_" + financialTransactionDetail.Id.ToString();
                                literalControl.Text = string.Format("<td>{0}</td>", financialTransactionDetail.Transaction.TransactionTypeValue);
                            }
                            else if (literalTableColumn.ID == "lMatchedRegistration")
                            {
                                if (financialTransactionDetail.EntityTypeId == registrationEntityTypeId && financialTransactionDetail.EntityId.HasValue)
                                {
                                    literalControl.ID   = "lMatchedRegistration_" + financialTransactionDetail.Id.ToString();
                                    literalControl.Text = string.Format("<td></td>");
                                }
                                else
                                {
                                    var tdEntityControls = new HtmlGenericContainer("td")
                                    {
                                        ID = "lMatchedRegistration_" + financialTransactionDetail.Id.ToString()
                                    };
                                    tr.Controls.Add(tdEntityControls);
                                    var ddlRegistration = new RockDropDownList {
                                        ID = "ddlRegistration_" + financialTransactionDetail.Id.ToString(), EnhanceForLongLists = true
                                    };
                                    ddlRegistration.Label                 = "Registration";
                                    ddlRegistration.AutoPostBack          = true;
                                    ddlRegistration.SelectedIndexChanged += ddlRegistration_SelectedIndexChanged;
                                    tdEntityControls.Controls.Add(ddlRegistration);
                                }
                            }
                            else if (literalTableColumn.ID == "lButton")
                            {
                                var tdEntityControls = new HtmlGenericContainer("td")
                                {
                                    ID = "pnlBtnControls_" + financialTransactionDetail.Id.ToString()
                                };
                                tr.Controls.Add(tdEntityControls);
                                var lbDelete = new LinkButton {
                                    ID = "lbDelete_" + financialTransactionDetail.Id.ToString()
                                };
                                lbDelete.CausesValidation = false;
                                lbDelete.Click           += lbDelete_Click;
                                HtmlGenericControl buttonIcon = new HtmlGenericControl("i");
                                buttonIcon.Attributes.Add("class", "fa fa-close");
                                lbDelete.Controls.Add(buttonIcon);
                                tdEntityControls.Controls.Add(lbDelete);
                                lbDelete.Visible = financialTransactionDetail.EntityTypeId == registrationEntityTypeId && financialTransactionDetail.EntityId.HasValue;
                            }
                        }
                    }

                    phTableRows.Controls.Add(tr);

                    pnlTransactions.Visible = true;
                }
            }
            else
            {
                pnlTransactions.Visible = false;
            }
        }