public static string HTMLTableWithCellContents(string strTableID, int numberOfColumns, List <string> contents) { NumberOfColumnsInFileBrowseTable = numberOfColumns; HTMLTable table = new HTMLTable(strTableID); /*HTMLTableRow topRow = new HTMLTableRow(); * HTMLTableCell topCell; * for (int i = 0; i < numberOfColumns; i++) * { * topCell = new HTMLTableCell(" ", "column" + (i + 1).ToString()); * topRow.AddCell(topCell); * } * table.Rows.Add(topRow); */ int currentColumnCounter = 0; HTMLTableRow currentRow = new HTMLTableRow(); foreach (string strContent in contents) { HTMLTableCell currentCell = new HTMLTableCell(strContent); currentRow.AddCell(currentCell); if (moveColumn(ref currentColumnCounter) == 0) { // Add last row? if (currentRow != null) { table.Rows.Add(currentRow); } // Create new row currentRow = new HTMLTableRow(); } } // Final row in progress? if (currentRow.Cells.Count > 0) { // Pad out row with empty cells if required if (currentColumnCounter != 0) { while (moveColumn(ref currentColumnCounter) != 0) { currentRow.AddCell(" "); } } table.Rows.Add(currentRow); } // Write table return(table.ToString()); }
public static string HTMLTableWithCellContents(string strTableID, int numberOfColumns, List<string> contents) { NumberOfColumnsInFileBrowseTable = numberOfColumns; HTMLTable table = new HTMLTable(strTableID); /*HTMLTableRow topRow = new HTMLTableRow(); HTMLTableCell topCell; for (int i = 0; i < numberOfColumns; i++) { topCell = new HTMLTableCell(" ", "column" + (i + 1).ToString()); topRow.AddCell(topCell); } table.Rows.Add(topRow); */ int currentColumnCounter = 0; HTMLTableRow currentRow = new HTMLTableRow(); foreach (string strContent in contents) { HTMLTableCell currentCell = new HTMLTableCell(strContent); currentRow.AddCell(currentCell); if (moveColumn(ref currentColumnCounter) == 0) { // Add last row? if (currentRow != null) table.Rows.Add(currentRow); // Create new row currentRow = new HTMLTableRow(); } } // Final row in progress? if (currentRow.Cells.Count > 0) { // Pad out row with empty cells if required if (currentColumnCounter != 0) { while (moveColumn(ref currentColumnCounter) != 0) { currentRow.AddCell(" "); } } table.Rows.Add(currentRow); } // Write table return table.ToString(); }