I have a simple aspx page with a GridView control. I\'m loading the GridView with search results after the click of a button. Everything works, but the HTML rendering on the bro
If you need ViewState on the control, you can reduce the ViewState impact the GridView has on the page by disabling the ViewState on each row in the PreRender event:
Private Sub grid_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles grid.PreRender
For Each item As DataGridItem In grid.Items
item.EnableViewState = False
Next
End Sub
Since the network is the bottleneck in this case, try to minify the resulting HTML. Apparently, the weight of each grid row is about 640 bytes on average (2500 records generate 1.6M payload). See if you can reduce it by removing unnecessary spaces and shortening any HTML elements IDs. Move styling, if any, from the grid to CSS, as was suggested before. If grid renders any URLs (e.g. “href” in anchors or “src” in images) try to shorten them. Also, if HTML rendered by GridView is not optimal see if you can render yourself. In order to estimate the anticipated page response time in production, factor-in your average user network speed (that may be different from the network speed of your machine).
If none of the above produce satisfactory result you may check the solution that we have – ASP.NET accelerator called Web Stimulus. It partially executes ASP.NET page code on the client to render the HTML on the client computer. Typical traffic reduction is 10-20 times with minimal code change.
Some simple suggestions, turn off the view state on that control. Also are you using MS AJAX, that can also cause problems. Take it out of the update panel if you are.
In short, do custom paging, so that it won't load all items on page load. Linq Data Source does it for you.
Why don't you want to use paging? 1.6 MB is a lot for the html of a page.
Considering you already disabled viewstate, look into reducing the amount of html by:
If you're not already compressing the HTTP Response, you should look into doing that.