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

DataBind Performance Issue

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
asilioni
Top achievements
Rank 1
asilioni asked on 24 Oct 2013, 10:59 AM
Hi,
we have a RadGrid control which has custom paging enabled. The maximum page size is equal to 50 records.
When the selected page size is equal to 30 records, the DataBind takes about 3 seconds to complete and the time is increased when page size increases.

Each GridTemplateColumn consists of a literal control which value is set in the DataBind event (see the code below).

 

 

<custom:RequestUrgency DataField="SolverUrgencyId" Groupable="false" FilterControlWidth="180px" HeaderText="Αμεσότητα" UniqueName="RequestSolverUrgency">

 <headerstyle width="15%" />

<ItemTemplate>

<asp:Literal ID="litSolverUrgencyId" runat="server" Text='<%# Eval("SolverUrgencyId") %>'>

 </asp:Literal>

</ItemTemplate>

 </custom:RequestUrgency>

 



The value of the literal changes to the DataBind event as below

 

 

protected void gridRequests_ItemDataBound(object sender, GridItemEventArgs e)

 

{

    try

    {

 

 

        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)

       {
            #region Urgency

 

 

 

            Literal litSolverUrgencyId = (Literal)e.Item.FindControl("litSolverUrgencyId");

 

            dt = DAL.GetServiceRequestUrgency(request.SolverUrgencyId);

 

            litSolverUrgencyId.Text = dt.Rows[0]["Title"].ToString(); 
 

            #endregion

 

        }

 

// if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)

 

    }

    catch
    {
    }
}

The RadGrid consists of 24 columns.
How can we reduce the DataBind time??

Thank you very much,
Angie

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 29 Oct 2013, 11:58 AM
Hello Angie,

The DataBind() method is used for simple data binding. As the name implies it is recommended when the RadGrid is used in a simple scenario where complex operations like updating, inserting, deleting, paging etc. are not needed. With simple data binding the DataBind() method should be called after every operation for the RadGrid.

In case you need to display large amount of data and use paging/sorting/filtering it is recommended to use advanced data binding. This could be done by setting the RadGrid's data source declaratively or usnig the NeedDataSource event.

Illustration of the two methods is available in this online demo.

I hope this information would be helpful.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
asilioni
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or