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
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
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.
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.
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.
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