tags:

views:

88

answers:

2

I am using a string builder to set up an html table row by row so that it can be emailed. I currently gather my information from the database using a data reader and while dataReader.read, I use stringbuilder.Append to add each cell value to the table.

The issue is that after about 200 rows, the html breaks and displays a cell value above the table in the email. I have tried changing the cell padding, but this was not successful. Any suggestions or ideas on why my html table is breaking would be greatly appreciated.

Thanks in advance, and I apologize for the lack of detail in my question.

A: 

Try running your output through a validator. I suspect you are closing a TR early.

lod3n
A: 

The other thing that could be breaking your markup - especially if the rows are all built with the same code, but the breakage doesn't occur until partway down the table - is if your cell data contains '<' or '>' characters.

If it does, these need to be changed to '&lt;' and '&gt;' respectively. As you state that you're using vb.net, I suspect that you'll be able to use something like Html.Encode - which is available in c# (Can't say for sure, as I've never used vb.net)

belugabob
I have checked this, and there are no '<' or '>' characters in this dataset. This is a good thing to watch out for in the future though, Thanks. I have also tested my code in FireFox and it works as expected. It seems that the HTML is breaking in IE only.
Have you got HTML validator installed? This is a good tool for checking that your markup is well formed. Just because a page works in one browser, doesn't mean that it is correct - could just be that the browser in question is more tolerant of the fault
belugabob
I concur with belugabob. If such errors occur, always run your code through an HTML Validator. You would be surprised how easy it is to miss something.
Edelcom