Topic: Character Delimiting an Array into a table
C# - Character Delimiting an Array
private void RebuildTable()
{
string[] arrWords;
string strWords;
TableRow rowNew;
TableCell celNew;
// For each string saved in ViewState
for (int iCount1 = 0; iCount1 < ViewState.Count; iCount1++)
{
// characters to delimit by
char[] strSep = {',', ';'};
// Create a new table row
rowNew = new TableRow();
// Get the string from ViewState
strWords = ViewState[iCount1.ToString()].ToString();
// Break the item list into an array
arrWords = strWords.Split(strSep);
// For each item in the array
for (int iCount2 = 0; iCount2 <= arrWords.GetUpperBound(0); iCount2++)
{
// Create a new table cell
celNew = new TableCell();
// Set the text to display in the cell
celNew.Text = arrWords[iCount2];
// Add the cell to the table row
rowNew.Cells.Add(celNew);
}
// Add the row to the table
tbl_Add.Rows.Add(rowNew);
}
}