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

RadGrid and NeedDatasource

1 Answer 631 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 2
Iron
Iron
Iron
Roger asked on 26 Sep 2019, 08:03 PM

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.

 

Roger

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 01 Oct 2019, 07:08 PM

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.
Tags
Grid
Asked by
Roger
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Attila Antal
Telerik team
Share this question
or