开发者

ASP.NET amount of data transfered with a repeater really high

I was busy implementing a repeater in an ASP.NET 4.0 to display data that I got开发者_JAVA百科 from the database, I didn't start with building in paging so at the start allot of data was transfered. I filled a datatable and bound it as the datasource of my repeater.

I noticed the following, while the page was busy loading 4000 records(way to much ofc) 26mb was transfered. This is allot, so I got curious and implementer displaying the same data/html with a for each loop (ofc this is not a good solution load time wise). When the page was loading 10.5 mb was transfered this time.

How come that when using a repeater 26 mb (24 with viewstate disabled) is transfered, and when creating the HTML with a loop 10 mb? Is there anyway to optimize the repeater? I implemented just the basic(creating itemtemplate, filling datatable from database and binding it to the repeater)


The repeater will only output the code that you tell it to. So I would do what @Aristos said in their comment and compare the markup returned. If you could post the markup for the first record in both cases, that would be helpful for us to answer your question.

One other thing you might look at that I have come accross a couple of times. In Firefox in particular, if you have an empty javascript link like the one below, the entire markup of the page is retrieved rather than just nothing. Now this might just be a bug in the Firebug Add-On, but it might explain the doubling of the download size. Although I am not sure why this would be caused by using a repeater without seeing some code. It is worth bearing in mind.

<script type="text/javascript" src="" ></script>


I've run into similar problems. My first line of defense was removing all the white space from within the repeater's template. This reduced the volume of data by about half (3.7 MB to 1.6MB) on a repeater that had 1600 repetitions. Since it's so easy to do ( in visual studio edit->advanced->remove horizontal whitespace) it's worth doing first thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜