Asp.net gridview vs writing innerhtml
I am going to suggest an alternative solution. If you don't need any of the features of the GridView why not use a relay.
A repeater simplifies implementation, but also allows you to have complete control over the generated source. No question about doing the concatenation sequence.
I found minor performance improvements with repeaters over GridViews.
source to share
No, there are no benefits to using a GridView. In general, the GridView will have a slight performance hit due to the items being written to the ViewState and additional HTML is generated. The benefits you get from a GridView include command events and arguments that you can easily consume or create, a DataKey property bag that lets you keep track of critical fields in a large result set, and much more. I'll add this caveat that I've used GridViews even with very simple return results and haven't seen any major performance issues.
If you're just drawing some kind of inference from a table query, and you're not worried about interacting too much with the data from the results themselves, "folding your own" will provide a great solution.
source to share
Well of course it depends on your implementation. You could almost certainly build something that runs faster than a stock gridview.
The problem is, how would you know? The default system for string concatenation in .Net is inherently very slow, so it would be easy to accidentally create something much slower than a gridview. You can of course check everything, but the investment in development time will probably outweigh the profit on server performance.
source to share
There is an additional opportunity here between using a GridView and using a StringBuilder to generate HTML. I'm talking about using the ASP Table class. I've seen impressive benefits of using them over a standard GridView where all I do is spit out the data. As an added bonus, I can add a button (or link) to my output and bind it to an event handler and still receive the GridView functionality in that regard.
You would use it this way:
Dim tab As New Table
For Each row In DataTable.Rows
Dim tabRow as New TableRow
For Each col In row.Columns
dim tabCol as New TableColumn
tabCol .Text = row(col)
tabRow.Controls.Add(tabCol )
Next
tab.Rows.Add(tabRow)
Next
Page.Controls.Add(tab)
source to share