If dtCurrentTable.Rows.Count > 0 Then '//Next collection. Spouse Information For Each row As DataRow In dtCurrentTable.Rows Dim txtsourcen As String = TryCast(row.ItemArray(1), String) Dim txtsourcea As String = TryCast(row.ItemArray(2), String) Dim txtsourcei As String = TryCast(row.ItemArray(3), String) lblPreviewSourceName.Text += txtsourcen & "<br />" lblPreviewSourceAddress.Text += txtsourcea & "<br />" lblPreviewIncomeSource.Text += txtsourcei & "<br />" 'get the values from the TextBoxes 'then add it to the collections with a comma "," as the delimited values sc.Add(lblPreviewSourceName.Text + "," + lblPreviewSourceAddress.Text + "," + lblPreviewIncomeSource.Text) rowIndex += 1 Next
the existing labels are printing the data at property level (like: Name, Address, Income) and now you want to print the data at record level (group those properties together).
hence, you may just need to use one label with this code: (not really tested, you may customize accordingly)
If dtCurrentTable.Rows.Count > 0 Then '//Next collection. Spouse Information Dim output As String = ""; lblPreviewSourceName.Text = "" For Each row As DataRow In dtCurrentTable.Rows Dim txtsourcen As String = TryCast(row.ItemArray(1), String) Dim txtsourcea As String = TryCast(row.ItemArray(2), String) Dim txtsourcei As String = TryCast(row.ItemArray(3), String) output = "Name: " & txtsourcen & "<br />Address: " & txtsourcea & "<br />Income: " & txtsourcei & "<br />" lblPreviewSourceName.Text += output & "<br />" sc.Add(lblPreviewSourceName.Text + "," + lblPreviewSourceAddress.Text + "," + lblPreviewIncomeSource.Text) rowIndex += 1 Next End If
hence, you may just need to use one label with this code: (not really tested, you may customize accordingly)
Open in new window