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

Data only displays from Page_Load??

5 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 19 Oct 2018, 04:37 PM

I have a RadGrid that becomes "visible" after a user clicks a button.  List of objects are assigned to the grid.  However the grid is showing nothing (I see only the grid border), not even the headers or anything and the DataBinding event is NOT triggered.  I've verified all the DataField names match up correctly to the List of Object properities … all good.

As an experiment, I moved the exact same code into my Page_Load event and it populates the grid as expected??

Do RadGrids ONLY work from Page_Load?

Baffled,

Any suggestions?

 

 

5 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 19 Oct 2018, 05:01 PM
Hi Rob,

If you are providing a data source to the grid in the code-behind, the best place to do that is its NeedDataSource event handler. The following article can be a good starting point: https://www.telerik.com/support/kb/aspnet-ajax/grid/details/how-to-bind-radgrid-properly-on-server-side.


Regards,
Marin Bratanov
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.
0
Rob Ainscough
Top achievements
Rank 1
answered on 19 Oct 2018, 05:42 PM

Marin,

So you're saying it's "by design" that the Grid's datasource will not update in any event other than Page_Load?  That doesn't sound right?

Rob.

0
Rob Ainscough
Top achievements
Rank 1
answered on 19 Oct 2018, 05:52 PM

Ok, the magic word I was looking for is apparently .Rebind().  So that issue is solved, but for some strange reason my RadRadioButton (GridTemplateColumn) is not firing the "OnCheckedChanged" event?

Any hints?

Rob.

 

0
Rob Ainscough
Top achievements
Rank 1
answered on 19 Oct 2018, 06:10 PM

Ignore, I had a Password validation field (RadTextBox) that got reset after the Grid.Rebind so it was blocking events until validation was cleared.

Thanks for the help.

Rob.

0
Marin Bratanov
Telerik team
answered on 22 Oct 2018, 10:26 AM
It's good to hear you have resolved this, Rob.
To add a some info on the grid events - while you could provide a data source to it in other events (including postback events such as button.Click), then callings its .DataBind() or .Rebind() method would likely bind the grid to that data, this is not what we recommend, because the rich feature set of the grid may require that it is provided with data in other cases/events too, and if this is not done, such simple data binding will fail. This is why we created the NeedDataSource event, so it can serve as a single place where you provide the same data to the grid every time without worrying for the page lifecycle.
--Marin
Tags
Grid
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Rob Ainscough
Top achievements
Rank 1
Share this question
or