使用datagrid使用AJAX的最佳实践是什么?

时间:2021-04-01 20:04:22

I have a Data Grid and an Update Panel. Now, I was just looking over some blogs and found that you should use the least amount of Update Panels as you can. In my case, where I have a Datagrid and an Update Panel, which would be the best situation?

我有一个数据网格和一个更新面板。现在,我只是浏览了一些博客,发现你应该尽可能少地使用更新面板。在我的例子中,我有一个Datagrid和一个更新面板,哪个是最好的情况?

1) Keep the Datagrid inside the Update Panel.

1)将Datagrid保存在更新面板中。

2) Use an Update Panel inside ItemTemplates. So that only if I update only the selected row is updated not the whole grid.

2)在ItemTemplates内使用更新面板。因此,只有当我只更新选定的行而不是整个网格时,才会更新。

2 个解决方案

#1


2  

Unfortunately, unless your DataGrid is very large, it won't make much difference either way.

不幸的是,除非您的DataGrid非常大,否则这两种方式都不会有太大的区别。

The majority of your overhead is usually in reinstantiating the Page. Even if your UpdatePanel is only sending back one rendered row, the entire Page, including the entire DataGrid, must be re-created and rendered before the pertinent section of HTML can be extracted and sent back to the browser.

你的大部分开销通常是在重新插入页面。即使您的UpdatePanel只发送回一个已呈现的行,也必须重新创建和呈现整个页面,包括整个DataGrid,然后才能提取HTML的相关部分并将其发送回浏览器。

If what you have is working, I'd leave it alone and concentrate any ongoing efforts on a more client-centric approach, which is where huge performance gains are to be had.

如果您所拥有的是有效的,那么我将把它放在一边,将所有持续的工作集中在更以客户为中心的方法上,这是获得巨大性能收益的地方。

#2


1  

If performance is your goal, start with the DataGrid. The amount of garbage it stores in viewstate is amazing.

如果性能是您的目标,那么从DataGrid开始。它在viewstate中存储的垃圾数量惊人。

UpdatePanel's in and of themselves aren't anywhere near as bad as a DataGrid.

UpdatePanel本身并没有DataGrid那么糟糕。

#1


2  

Unfortunately, unless your DataGrid is very large, it won't make much difference either way.

不幸的是,除非您的DataGrid非常大,否则这两种方式都不会有太大的区别。

The majority of your overhead is usually in reinstantiating the Page. Even if your UpdatePanel is only sending back one rendered row, the entire Page, including the entire DataGrid, must be re-created and rendered before the pertinent section of HTML can be extracted and sent back to the browser.

你的大部分开销通常是在重新插入页面。即使您的UpdatePanel只发送回一个已呈现的行,也必须重新创建和呈现整个页面,包括整个DataGrid,然后才能提取HTML的相关部分并将其发送回浏览器。

If what you have is working, I'd leave it alone and concentrate any ongoing efforts on a more client-centric approach, which is where huge performance gains are to be had.

如果您所拥有的是有效的,那么我将把它放在一边,将所有持续的工作集中在更以客户为中心的方法上,这是获得巨大性能收益的地方。

#2


1  

If performance is your goal, start with the DataGrid. The amount of garbage it stores in viewstate is amazing.

如果性能是您的目标,那么从DataGrid开始。它在viewstate中存储的垃圾数量惊人。

UpdatePanel's in and of themselves aren't anywhere near as bad as a DataGrid.

UpdatePanel本身并没有DataGrid那么糟糕。