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

[Solved] NeedDataSource firing with RebindReason InitialLoad before UpdateCommand

2 Answers 290 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy Morris
Top achievements
Rank 1
Andy Morris asked on 03 Nov 2009, 04:52 PM
I am using a RadGrid and the advanced data binding method via the NeedDataSource event. I am actually using this same setup in several areas of my app, but this is the only one that is behaving incorrectly. I am also using EditFormSettings with EditFormType="Template", and I have a GridTemplateColumn which has a button whose CommandName is RadGrid.EditCommandName. This causes my edit form template to show, and that works correctly. The template contains a button with CommandName of RadGrid.UpdateCommandName.

This is where the problem occurs, because NeedDataSource fires with RebindReason of GridRebindReason.InitialLoad BEFORE the UpdateCommand event fires. UpdateCommand does fire, and I am able to get values from my edit form template and save correctly, but because NeedDataSource fires before that, the Grid row of the item that was just edited shows the old values after it hides the edit form. I have tried calling Rebind after saving in my UpdateCommand handler, but that has no effect.

Any help is greatly appreciated.

2 Answers, 1 is accepted

Sort by
0
Andy Morris
Top achievements
Rank 1
answered on 04 Nov 2009, 03:06 PM
Update: NeedDataSource (again with RebindReason == InitialLoad) is actually firing on every request. If I click another button on the page that causes either a full or partial postback, NeedDataSource fires every single time.

I have also checked and EnableViewState is true on the RadGrid, and ViewStateSize hovers around 840.
0
Veli
Telerik team
answered on 06 Nov 2009, 08:32 AM
Hello Andy,

Make sure you do not call Rebind() on every postback and no parent's ViewState is switched off. Also, if you are dynamically loading some user control with the grid or some other scenario, where your ViewState is not properly saved/restored, you may get RadGrid rebinding on every postback. In the general case, RadGrid should not rebind on every postback, as it restores its state from the ViewState.

If the problem persists, please, consider sending some sample code we can examine. Providing any details related to the grid's binding would be helpful too.

All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Andy Morris
Top achievements
Rank 1
Answers by
Andy Morris
Top achievements
Rank 1
Veli
Telerik team
Share this question
or