RadGrid NeedDataSource firing before rebind()

2 posts, 0 answers
  1. Pedro
    Pedro avatar
    4 posts
    Member since:
    Oct 2014

    Posted 18 Jan 2017 Link to this post


    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;
  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 23 Jan 2017 Link to this post

    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.
Back to Top