LoadControl/用户控件(ascx)的上限 [英] Upper limit to LoadControl / user controls (ascx)
本文介绍了LoadControl/用户控件(ascx)的上限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查找一些信息,以提出有关使用用户控件的最佳做法.想象一下,您有一个带有TemplateField的GridControl,后者又加载了一个控件.
I''m trying to find some information suggesting best practices regarding the use of usercontrols. Imagine you have a GridControl with a TemplateField which in turn loads a control.
public class GridColumnTemplateCommand : ITemplate
{
#region ITemplate Members
public void InstantiateIn(Control container)
{
if (HttpContext.Current.CurrentHandler is Page)
{
Page page = (Page)HttpContext.Current.CurrentHandler;
Control cActionCell = page.LoadControl(@"~\Shared\Controls\ControlShoppingListTableCellAction.ascx");
container.Controls.Add(cActionCell);
}
}
#endregion
}
这将意味着对每个单元都进行LoadControl.如果此网格绑定到足够大的数据集,我会担心性能.我的直觉说转换为服务器控件,但我找不到支持该控件的证据.
This would mean that LoadControl occurs for every cell. If this grid was bound to a sufficiently large dataset I am concerned about performance. My gut says convert to a server control, but I can''t find evidence to support this. Can anyone poine me to any information confirming my gut instinct?
推荐答案
您不会为此找到最佳实践,因为它涉及太多变量.在不同的硬件和连接方案下,性能可能会有所不同.即使使用服务器控制数据量,也可能是视图状态,仍然可能是性能问题.最好的方法是检查设计并在可能的情况下进行简化,以其他方式显示数据,或者根据需要动态加载一些数据.
You are not going to find a best practice for this as it involves too many variables. Performance can be different with different hardware and connection scenarios. Even it you used a server control the amount of data, and perhaps viewstate, may still be a problem for performance. The best approach is to review the design and simplify if possible, present the data in a different manner, or maybe load some data dynamically as necessary.
这篇关于LoadControl/用户控件(ascx)的上限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文