RadGrid and NeedDatasource

2 posts, 0 answers
  1. Roger
    Roger avatar
    10 posts
    Member since:
    Apr 2019

    Posted 26 Sep 2019 Link to this post

    I have a radgrid I fill in a procedure.

    I do some custom adding of datatable, then some custom columns.


    All of this works great, until a postback, then the Grid Goes blank.


    I have read in several places I need to "Refill" the grid in the NeedDataSource.

    So do I duplicate everything in the Procedure I use to fill it and format columns etc.

    Some of the formating I do on the grid involves adding new colunms  and switching columns.


    Some of the items involve a databind before I can do the formating.  And in NeedDatasource I cannot do a databind.


    So I am a little lost in how to handle this situation.


    Thanks in advance.



  2. Attila Antal
    Attila Antal avatar
    520 posts

    Posted 01 Oct 2019 Link to this post

    Hi Roger,

    It is not about the procedure. It can be a simple SQL Query, or just a List<Of String> that is bound to the Grid. The problem mainly is because of the way this data is bound to RadGrid. DataBind() method breaks it.

    Your finding is correct and I also recommend using either the Advanced DataBinding with NeedDataSource event, or bind data to RadGrid using Declarative DataSource.

    Here is a KB article mentioning the same: How to bind RadGrid properly on server-side

    You can check out the following samples. They all use Advanced Data Binding:

    Also I have attached another sample project demonstrating RadGrid with Advanced DataBinding and Hierarchy.

    Kind regards,
    Attila Antal
    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