Remove breakLine between td in sourceCode

Public Function GenerateHtmlReport(ByVal ResultDataset As System.Data.DataSet) As String Implements IValidation.GenerateHtmlReport
        Dim _StrBuil As New StringBuilder()
        Dim clsHtmlBuilder As New HtmlBuilder()
        Try
            _StrBuil.AppendLine(Space(2) & clsHtmlBuilder.AddHr())
            _StrBuil.AppendLine(Space(3) & clsHtmlBuilder.TextBig(ResultDataset.DataSetName))
            _StrBuil.AppendLine(Space(5) & clsHtmlBuilder.AddLineBreak)

            For Each _Tbl As DataTable In ResultDataset.Tables
                If _Tbl Is Nothing OrElse _Tbl.Rows.Count = 0 Then Continue For
                _StrBuil.AppendLine(Space(8) & clsHtmlBuilder.StartTable())

                'set Table Header
                'set Table Name

                _StrBuil.AppendLine(Space(15) & clsHtmlBuilder.StartH4())
                _StrBuil.AppendLine(Space(20) & _Tbl.TableName)
                _StrBuil.AppendLine(Space(15) & clsHtmlBuilder.EndH4())
                _StrBuil.AppendLine(Space(25) & clsHtmlBuilder.StartTableRow())

                'set Column Name
                For Each _col As DataColumn In _Tbl.Columns
                    _StrBuil.AppendLine(Space(35) & clsHtmlBuilder.StartTableHeader())
                    _StrBuil.AppendLine(Space(45) & _col.ColumnName)
                    _StrBuil.AppendLine(Space(35) & clsHtmlBuilder.EndTableHeader())

                Next
                _StrBuil.AppendLine(Space(25) & clsHtmlBuilder.EndTableRow())

                'set Table Rows
                For Each _dr As DataRow In _Tbl.Rows
                    _StrBuil.AppendLine(Space(25) & clsHtmlBuilder.StartTableRow())
                    For Each _col As DataColumn In _Tbl.Columns
                        If (Space(45) & _col.ColumnName = "Result") Then
                            _StrBuil.AppendLine(Space(35) & clsHtmlBuilder.StartTableCell())
                        Else

                            _StrBuil.AppendLine(Space(35) & clsHtmlBuilder.StartTableCell())

                        End If
                        _StrBuil.AppendLine(Space(45) & _dr(_col.ColumnName).ToString())
                        _StrBuil.AppendLine(Space(35) & clsHtmlBuilder.EndTableCell())

                    Next

                    _StrBuil.AppendLine(Space(25) & clsHtmlBuilder.EndTableRow())
                Next

                _StrBuil.AppendLine(Space(8) & clsHtmlBuilder.EndTable())
            Next
            _StrBuil.AppendLine(Space(5) & clsHtmlBuilder.AddLineBreak)
            _StrBuil.AppendLine(Space(2) & clsHtmlBuilder.AddHr())
        Catch ex As Exception
            clsCommon.writeErrorLog("Error in Report Generation", "RuleSet2", "GenerateHtmlReport")
            Throw ex
        End Try
        Return _StrBuil.ToString()
    End Function
End Class

souce code :

 <td nowrap = "nowrap">
         4F0B52DC0001
 </td>
 <td nowrap = "nowrap">
         C006411
 </td>
 <td nowrap = "nowrap">
         Christiansen
 </td>
 <td nowrap = "nowrap">
         Cathy
 </td>
 <td nowrap = "nowrap">
         19570406
 </td>
 <td nowrap = "nowrap">

 </td>

Answers


Do you mean that you want the following?

<td nowrap = "nowrap">4F0B52DC0001</td>
<td nowrap = "nowrap">C006411</td>
<td nowrap = "nowrap">Christiansen</td>
<td nowrap = "nowrap">Cathy</td>
<td nowrap = "nowrap">19570406</td>
<td nowrap = "nowrap"></td> 

Try this:

For Each _col As DataColumn In _Tbl.Columns
    If (Space(45) & _col.ColumnName = "Result") Then
        _StrBuil.Append(Space(35) & clsHtmlBuilder.StartTableCell())
    Else
        _StrBuil.Append(Space(35) & clsHtmlBuilder.StartTableCell())
    End If
    _StrBuil.Append(_dr(_col.ColumnName).ToString())
    _StrBuil.AppendLine(clsHtmlBuilder.EndTableCell())
Next 

(Use Append instead of AppendLine)

If you try asking a clearer question, you may get a more relevant answerer.


EDIT: In response to your comment, you can remove the gap between the last (empty) table cell by checking to make sure that the "attribute" value is not blank or null. The line of code that's causing your problems is:

_StrBuil.AppendLine(Space(45) & _dr(_col.ColumnName).ToString()) 

This will print a line of text (with a new line character at the end) whether or not _dr(_col.ColumnName) represents a non-null/non-blank value. Wrap this satement if an if-block that ensures it is only executed if _dr(_col.ColumnName) is not null and not blank. You can use .Trim() to remove white-space from the value and String.IsNullOrEmpty() to make sure that there's a non-blank value represented by the string.


EDIT: For more information, please see the following links:

Think about what you want to accomplish, then write it down as a series of steps (maybe on paper first, then in code). If you cannot do that, then you cannot program (HINT: Almost anyone can program).


Need Your Help

Instances of my class don't want to act properly as dictionary keys interchangeably with strings

c# dictionary wrapper equals gethashcode

I created a sort of string wrapper class and want to use its instances as dictionary keys interchangeably with usual strings. I overrode GetHashCode and Equals and got results that seem strange. I've

Accessing Data across two Databases

java spring mongodb

I have large set of data(more than 1TB). This will be accessed by more than 1000 people concurrently. Storing it in one database will make the application really slow. So I was planning to store it