This is a migrated thread and some comments may be shown as answers.

Multiple RadComboboxes in GridView, Bad performance

5 Answers 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
klaas
Top achievements
Rank 1
klaas asked on 15 Sep 2010, 11:12 AM
Hi,

I'm trying to create a gridview with multiple columns that can contain different kinds of System.Web.UI.Controls in Code-Behind. One of them is a radComboBox.
When I add the radComboBox performance drops down dramatically, but I can't find the exact problem.
Is there something I am doing wrong, or is this a known issue?

Below is the Code-Behind file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
using System.ComponentModel;
using System.Collections;
using System.Collections.Specialized;
 
namespace WebApplication1
{
     
    // Default Page
    public partial class _Default : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
 
            if (IsPostBack)
                createStaticControls();           
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                createStaticControls();           
        }
 
 
        private void createStaticControls()
        {
            int index = 0;
 
            GridViewExtension gridView = new GridViewExtension();
            gridView.EnableInsert = true;
            gridView.rowSize = 20;
            Panel1.Controls.Add(gridView);
 
            while (index != 5)
            {
                TemplateField tfield = new TemplateField();
                tfield.Visible = true;
                tfield.ItemTemplate = new DynamicControl(index);
                tfield.HeaderText = index.ToString();
                gridView.Columns.Add(tfield);
 
                index++;
            }
 
            gridView.DataBind();
 
            Button b = new Button();
            Panel1.Controls.Add(b);
        }
    }
 
 
    // Control - ITemplate, now always an RadComboBox
    public class DynamicControl : ITemplate
    {
        private int index;
 
        public DynamicControl(int _index)
        {
            index = _index;
        }
 
        public void InstantiateIn(System.Web.UI.Control container)
        {
            RadComboBox realControl = new RadComboBox();
            //Label realControl = new Label();      // Label much faster
 
            realControl.Enabled = true;
            realControl.Visible = true;
            realControl.ID = index.ToString();
            realControl.Text = index.ToString();
 
            container.Controls.Add(realControl);
        }
    }
 
 
    // GridView Extension, make empty rows with staticControls
    public class GridViewExtension : System.Web.UI.WebControls.GridView
    {
        public int rowSize;
        public bool EnableInsert;
 
        // Override the creation of childControls to create empty rows
        protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding)
        {
            //create table
            Table table = new Table();
            table.ID = this.ID;
 
            //create a new header row
            GridViewRow row = base.CreateRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal);
 
            //convert the exisiting columns into an array and initialize
            DataControlField[] fields = new DataControlField[this.Columns.Count];
            this.Columns.CopyTo(fields, 0);
            this.InitializeRow(row, fields);
            table.Rows.Add(row);
 
            this.Controls.Add(table);
 
            while (rowSize != 0)
            {
                this.CreateInsertRow(rowSize, false);
                rowSize--;
            }
 
            return 0;
        }
 
        protected virtual void CreateInsertRow(int rowIndex, bool allowPaging)
        {
            GridViewRow row = this.CreateRow(rowIndex, -1, DataControlRowType.DataRow, DataControlRowState.Insert);
            row.ID = rowIndex.ToString();
 
            DataControlField[] fields = new DataControlField[this.Columns.Count];
            this.Columns.CopyTo(fields, 0);
 
            if (this.HasControls())
            {
                int index = ((Table)this.Controls[0]).Rows.Count - (this.ShowFooter ? 1 : 0) - (allowPaging ? 1 : 0);
                ((Table)this.Controls[0]).Rows.AddAt(index, row);
            }
 
            this.InitializeRow(row, fields);
        }
    }
}


Thanks,
Klaas

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 15 Sep 2010, 02:36 PM
Hello klaas,

How exactly does the performance drop and where - on the client or the server side? Do you have many (500+) Items in the RadComboBoxes?

All the best,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
klaas
Top achievements
Rank 1
answered on 15 Sep 2010, 03:34 PM
Hello Simon,

I have no items in the RadComboBox, the code posted is the only code in the project.
You can simply recreate my testproject if you create a new ASP.Net Web Application in Visual Studio 2010 and copy the given code in "Default.Aspx"

Lastly copy this in the markup:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
    </h2>
    <asp:Panel ID="Panel1" runat="server">
</asp:Panel>
</asp:Content>

I guess the delay is on the server side.

Thanks for the help.
Klaas
0
Simon
Telerik team
answered on 16 Sep 2010, 09:50 AM
Hello klaas,

Thank you for clarifying.

I recreated your page and noticed that you have a hundred RadComboBoxes on the page. In this case, it is normal to experience a performance drop. If you put any other more advanced control on a page in such high numbers you will experience the same. RadComboBox requires more server- and client-side processing than a standard DropDownList for example.

I suggest you reconsider your requirement or the control that you can use in this case instead of RadComboBox.

Kind regards,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Donnie
Top achievements
Rank 1
answered on 30 Nov 2010, 08:55 PM
Are there any plans in the works to improve the performance of the RadComboBox in IE? I have a similar issue to what's described above, that I am forced to find another (less desirable) solution for. I too have 100+ (only in some cases) RadComboBoxes in a template column of a datagrid. It renders perfectly fine in all other browsers (I know, it is IE after all). Unfortunately, due to legacy ActiveX controls, we only officially support IE for our SaaS product.

Truth is we love the Rad controls. We have been striving to find new ways to implement them into our product, but it simply cannot be an option with so much pre render overhead on the client side.

Have you considered the option of toggling off the unnecessary scripts on load? I would love to have the option of coding something like:

If MyDataGrid.Rows.Count > 50 Then
    MyRadComboBox.ActLikeRegularDropDownList = True
End If

A scaled down version that would maintain the free typing ability but lose the script registration required for unused animations and other client events.

If you have such an option available, or coming in a future release please let me know....we may be willing to change our development plans to accomodate the new assembly. Otherwise we have no choice but to abandon the rad Controls and redesign our product with something more practical.

I look forward to your response. Thanks.
0
Simon
Telerik team
answered on 03 Dec 2010, 06:27 PM
Hello Donnie,

Thank you for sharing your concerns.

We are aware of this 'limitation' of RadComboBox and will research a way to provide only those scripts, which are required by the currently enabled functions of the control. Hopefully we will have a concrete answer to the question whether it is possible or not by the end of the current Q. The positive case, the implementation will follow.

I hope this helps.

All the best,
Simon
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
ComboBox
Asked by
klaas
Top achievements
Rank 1
Answers by
Simon
Telerik team
klaas
Top achievements
Rank 1
Donnie
Top achievements
Rank 1
Share this question
or