Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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
}


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?
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900