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

RadGrid NeedDataSource firing before rebind()

1 Answer 470 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pedro
Top achievements
Rank 1
Pedro asked on 18 Jan 2017, 01:00 PM

Hi,

I have a radgrid with a lazy load method to handle the binding. The binding is done via a button's CustomParameter that, when it's clicked, provides the parameters for the query that populates the grid. Problem is: the Grid's NeedDataSource is triggered before the rebind call on the button's click event and messes up the whole thing.

Here is the grid NeedDataSource, where the 'bind' variable is to prevent the call when first accessing the page

protected void Quotas_Table_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
                if (bind && Session["SessionId"] != null)
                {
                    Quotas_Table.DataSource = Empresas_DAL.GetQuotasList((string)Session["TP_QT_" + (string)Session["SessionId"]], int.Parse((string)Session["PRD_QT_" + (string)Session["SessionId"]]), DateTime.Now.Year);
                }
        }

 

and here is the button's event, where all variables here are strings:

protected void Compilar_Click(object sender, EventArgs e)
        {
            LinkButton lnk = sender as LinkButton;
            string param = lnk.Attributes["CustomParameter"];
 
            tipo = param.Substring(0, 1);
            periodo = param.Substring(1);
 
            Session["TP_QT_" + (string)Session["SessionId"]] = tipo;
            Session["PRD_QT_" + (string)Session["SessionId"]] = periodo;
 
            bind = true;
            Quotas_Table.Rebind();
        }

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 23 Jan 2017, 07:20 AM
Hi Pedro,

This is the life cycle of the events and using global variables or a HiddenField for holding a flag is the only option that you have for achieving the desired result.

You can take a look at the following help article for the sequence of the RadGrid events:

Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Pedro
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or