PAWA.Classes.AdminReports.CreateTable C# (CSharp) Method

CreateTable() private method

private CreateTable ( int nColumns, string columnHeaders, List rows, string tableId = "", string headerClass = "" ) : string
nColumns int
columnHeaders string
rows List
tableId string
headerClass string
return string
        private string CreateTable(int nColumns, string[] columnHeaders, List<List<string>> rows, string tableId = "", string headerClass = "")
        {
            string table = "<table id=\"" + tableId + "\">\n    <tr>";
            int countRows = 0;

            // Add column headers
            foreach (var columnData in columnHeaders)
            {
                table += "\n        <td class=\"" + headerClass + "\">" + columnData + "</td>";
            }

            table += "\n    </tr>";

            // Add rows
            foreach (var row in rows)
            {
                table += "\n    <tr>";

                foreach (var columnData in row)
                {
                    table += "\n        <td";

                    if (countRows % 2 != 0)
                    {
                        table += " id=\"row-background-color\"";
                    }

                    table += ">" + columnData + "</td>";

                }

                table += "\n    </tr>";
                countRows++;
            }

            table += "\n</table>";

            return table;
        }