I'm having to build a table of web pages and languages, i.e. page 1: en it de in a schema where there could be up to 14 languages. The page contents are held in a database. So to build the table I'm doing the following:
Dim rowArrayList As New ArrayList
Dim thisRow(languageNum) As String 'languageNum equates to number of columns -1
Database access then:
'# Create row array of cell arrays
If pageName <> lastPageName Then
lastPageName = pageName
If j >= languageNum Then
rowArrayList.Add(thisRow)
Array.Clear(thisRow, 0, thisRow.Length)
j = 0
End If
thisRow(0) = "<td class=""pageName"">" & pageName & "</td>"
End If
'# Iterate each cell in the row
For i As Integer = 1 To languageNum - 1
If thisRow(i) = "" Then
If transReady = False And active = False Then
thisRow(i) = "<td class=""trans""><a href=""content/page-text.aspx?pageID=" & SQLReader("DAEPageContentControlID").ToString() & "&lang=" & langISO & """>" & langISO & "</a></td>"
ElseIf transReady = True And active = False Then
thisRow(i) = "<td class=""notActive""><a href=""content/page-text.aspx?pageID=" & SQLReader("DAEPageContentControlID").ToString() & "&lang=" & langISO & """>" & langISO & "</a></td>"
ElseIf transReady = True And active = True And i = thisLangID Then
thisRow(i) = "<td class=""active""><a href=""content/page-text.aspx?pageID=" & SQLReader("DAEPageContentControlID").ToString() & "&lang=" & langISO & """>" & langISO & "</a></td>"
End If
End If
j = j + 1
Next
The build the table:
'# Build output table
For Each row As String() In rowArrayList
tableBody.Text += "<tr>"
For Each cell As String In row
If cell = "" Then
tableBody.Text += "<td class=""notTrans""> </td>"
Else
tableBody.Text += cell
End If
Next
tableBody.Text += "</tr>"
Next
The table displays beautifully BUT every row contains the data for what should be the last row. How can it be fixed it so each thisRow is unique in the the rowArrayList? At the moment, every time thisRow is added to rowArrayList, every rowArrayList index is overwritten, not just the one being added.
RepeaterorGridViewinstead of creating html manually?