RadGrid not DataBound by PreRender

4 posts, 0 answers
  1. Diane
    Diane avatar
    10 posts
    Member since:
    Jul 2008

    Posted 23 Mar 2009 Link to this post


    I am having difficulty with the RadGrid control (inside a user control) not databinding items by the PreRender event. The documentation says the lifecycle is as follows:

    First page load:
    Foreach Item in Grid_Instance:

    I am binding to a ObjectDataSource control:

      <telerik:RadGrid ID="rgProgrammes" runat="server" AutoGenerateColumns="False"
      DataSourceID="ods_Programmes" GridLines="None" Skin="Office2007">
                    <MasterTableView DataKeyNames="pim_ID, CombinedCode" DataSourceID="ods_Programmes">

    (i also bind to a GridView to check if that works)
    Then in code behind I do a simple check for if it has databound :

        protected void Page_PreRender(object sender, EventArgs e)
            int test = rgProgrammes.Items.Count; //result = 0
            int test2 = GridView1.Rows.Count; //result = 3

    Have I misunderstood something about the lifecycle of the RadGrid? When I insert breakpoints in my code, the Page_PreRender
    event gets called before the RadGrid_DataBound event. This is giving me difficulty using a RadGrid in a user control

    Any help would be appreciated.

  2. Tsvetoslav
    Tsvetoslav avatar
    1823 posts

    Posted 26 Mar 2009 Link to this post

    Hello TomL,

    Please, note that the case you are looking at in the documentation uses the NeedDataSource event to bind the grid - in this case the event sequence follows precisely the one given in the help article. However, when you set the DataSourceID property of the grid - the sequence of the events on initial page load is different - the Page_Prerender event comes before the grid's ItemDataBound.

    Best Regards,
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Adam Hughes
    Adam Hughes avatar
    4 posts
    Member since:
    Jan 2019

    Posted 25 Apr 2019 Link to this post

    So, when client data binding, how to make sure PreRender comes after data has been bound?
  4. Eyup
    Eyup avatar
    3901 posts

    Posted 30 Apr 2019 Link to this post


    The PreRender event is raised on server-side. When using client-side binding for the grid, there is no data at server-side at all. The grid gets its content on client-side and you can use JavaScript function with the client-side events provided by the grid to capture this moment. For example - OnRowDataBound:

    I hope this will prove helpful.

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top