Hi,
I have the following issue:
I have a Radgrid, with the definition bellow, in a user control, in an AJAX page, deployed on sharepoint. On an AJAX event the grid is given a DataSet as DataSource and populated. If I change the page and open the edit form for a row the grid changes the page back to page one and opens in edit mode the corresponding row on that page. At a debug I've seen that needDataSource handler is called before ItemCommand handler. Do you have any idea why this happens?
I tried to isolate the code in a simple project but if I put the control with the grid in a simple AJAX page, it behaves normally.
Thank you,
Victor
<snt:CustomizedGrid ID="dgQResults" runat="server" Skin="Office2007" |
OnNeedDataSource="dgQResults_NeedDataSource" |
OnItemCommand="dgQResults_ItemCommand" |
OnPreRender="dgQResults_PreRender" |
OnItemCreated="dgQResults_ItemCreated" |
OnInsertCommand="dgQResults_InsertCommand" |
OnUpdateCommand="dgQResults_UpdateCommand" |
OnDeleteCommand="dgQResults_DeleteCommand" |
OnColumnCreated="dgQResults_ColumnCreated" |
OnPageIndexChanged="dgQResults_PageIndexChanged" |
Width="100%" Height="370px" |
AllowFilteringByColumn="True" |
ShowCustomFilters="true" |
AllowSorting="True" |
CustomEnableInsert="false" |
CustomEnablePrint="true" |
EnableLinqExpressions="false" |
AutoGenerateDeleteColumn="true" |
> |
<MasterTableView |
AutoGenerateColumns="True" |
RetrieveDataTypeFromFirstItem="true"> |
<Columns> |
<telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="/_layouts/SMISUGIS/Images/Arrow.png" UniqueName="SelectColumn" CommandName="DisplayObject"> |
</telerik:GridButtonColumn> |
<snt:CustomizedGridEditColumn></snt:CustomizedGridEditColumn> |
</Columns> |
<EditFormSettings ColumnNumber="2" > |
<FormTableItemStyle Wrap="False"></FormTableItemStyle> |
<FormMainTableStyle CellSpacing="0" CellPadding="3" BackColor="#FEFCE8" /> |
<FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" |
BackColor="#FEFCE8" /> |
<FormStyle Width="100%" BackColor="#FEFCE8"></FormStyle> |
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
<EditColumn ButtonType="ImageButton" |
CancelText = "Anuleaza" CancelImageUrl = "/_layouts/TabStrip/cancel.gif" |
InsertText="Adauga" InsertImageUrl = "/_layouts/TabStrip/save.gif" |
EditText = "Editeaza" EditImageUrl = "/_layouts/TabStrip/save.gif" |
UpdateImageUrl="/_layouts/TabStrip/save.gif" |
UniqueName="EditColumn"></EditColumn> |
<FormTableButtonRowStyle VerticalAlign="Bottom" HorizontalAlign="Left" ></FormTableButtonRowStyle> |
</EditFormSettings> |
</MasterTableView> |
</snt:CustomizedGrid> |
(The CutomizedGrid and CustomizedGridEditColumn extend the RadGrid and GridEditCommandColumn)
13 Answers, 1 is accepted
0
Hi Victor,
When RadGrid current page is changed, sort, filter or insert/update/delete operations are performed, RadGrid is being implicitly rebound. You can find more information on the RadGrid lifecycle in the below articles:
http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html
http://www.telerik.com/help/aspnet-ajax/grdcommandsthatinvokerebindimplicitly.html
All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
When RadGrid current page is changed, sort, filter or insert/update/delete operations are performed, RadGrid is being implicitly rebound. You can find more information on the RadGrid lifecycle in the below articles:
http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html
http://www.telerik.com/help/aspnet-ajax/grdcommandsthatinvokerebindimplicitly.html
All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Victor
Top achievements
Rank 1
answered on 17 May 2010, 03:39 PM
Hi Iana,
I know this. My problem is that it is not bound correctly on edit after a filter/page change/sort.
For example, what happens for a grid with 10 records per page is:
- I change to page 2
- I click on edit for record 17 on page 2
- Grid changes page back to page 1 and opens record 7 instead of 17.
Behind the scenes NeedDataSource is raised before ItemCommand.
Thank you,
Victor
0
Hi Victor,
A possible reason for the NeedDataSource event to be raised before the ItemCommand event is if the RadGrid ViewState is disabled. However in this case the NeedDataSource event will fire once again after the ItemCommand event.
Furthermore even in case the NeedDataSource event fires before the ItemCommand, this could not be a reason for the grid page index to change automatically. Could you please confirm you are not resetting it anywhere in code by mistake?
Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
A possible reason for the NeedDataSource event to be raised before the ItemCommand event is if the RadGrid ViewState is disabled. However in this case the NeedDataSource event will fire once again after the ItemCommand event.
Furthermore even in case the NeedDataSource event fires before the ItemCommand, this could not be a reason for the grid page index to change automatically. Could you please confirm you are not resetting it anywhere in code by mistake?
Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Victor
Top achievements
Rank 1
answered on 18 May 2010, 10:39 AM
Hi,
I do not set the viewstate to false for the grid or any other containing control (it wouldn't work perfectly in the simple test project if I did).
I do not set explicitly for a rebind: rebindReason is InitialLoad in NeedDataSource, and I do not modify the pageIndex anywhere.
Also, the problem isn't the gird control that derrives from RadGrid because it merely sets some common properties and I also tried with the RadGrid and the problem remains.
The version I use is 2009 Q3.
Thank you,
Victor
0
Hi Victor,
Could you please open a formal support ticket and send us a sample, or a runnable code, illustrating the issue in question?
We will debug it locally and turn back to you with our findings.
Other than this it is hard to determine the source of the problem based on the provided information.
Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Could you please open a formal support ticket and send us a sample, or a runnable code, illustrating the issue in question?
We will debug it locally and turn back to you with our findings.
Other than this it is hard to determine the source of the problem based on the provided information.
Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

VictorG
Top achievements
Rank 1
answered on 01 Jun 2010, 08:53 AM
Hi,
As a follow-up, after a lot of searching through the code I found the source of the problem. The odd behaviour of the grid (needDataSource before each command, filering or sorting was not persisted after page change etc) was caused by a piece of code in the CreateChildControls method of the page that was scanning the controls of the page recursively while setting TabIndex for input controls. This was somehow interfering with my grid.
private void ApplyTabIndex(ControlCollection ctrls, ref short tabIndex) |
{ |
foreach (Control c in ctrls) |
{ |
if (c is WebControl && (c is RadTextBox || c is RadNumericTextBox || c is RadDateInput || c is RadComboBox || c is TextBox || c is DropDownList || c is RadioButton || c is RadioButtonList || c is CheckBox)) |
{ |
(c as WebControl).TabIndex = tabIndex++; |
} |
ApplyTabIndex(c.Controls, ref tabIndex); |
} |
} |
Victor
0
Hello Victor,
I am glad that you were able to find a resolution for your case. And I hope sharing your experience will help other community users as well.
Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I am glad that you were able to find a resolution for your case. And I hope sharing your experience will help other community users as well.
Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Ambreen
Top achievements
Rank 1
answered on 22 Jul 2010, 07:10 PM
Hi,
I am having the same issue, NeedDataSource event is raised before ItemCommand event.
As a result, NeedDataSource does not get correct filter value.
Any solutions for this problem?
Thanks,
Ambreen
I am having the same issue, NeedDataSource event is raised before ItemCommand event.
As a result, NeedDataSource does not get correct filter value.
Any solutions for this problem?
Thanks,
Ambreen
0
Hello Ambreen,
In order to provide a resolution for your case, we need to find the cause of the issue first. Therefore can you provide the page code or a runnable sample for further research?
Sincerely yours,
Iana
the Telerik team
In order to provide a resolution for your case, we need to find the cause of the issue first. Therefore can you provide the page code or a runnable sample for further research?
Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Jeff Snyder
Top achievements
Rank 1
answered on 20 Sep 2010, 09:28 PM
I too am having an issue with custom paging. The NeedDataSource event is firing before the ItemCommand event or the PageIndexChanged event. I am unable to retrieve the correct set of records because the page index is not correct. I do not have ViewState disabled for the Grid, as was suggested might be a problem in a previous post. Has anyone determined other possible causes of this issue?
0

Stan
Top achievements
Rank 1
answered on 17 Apr 2012, 03:32 PM
That is exactly my problem as well. Here is the sequence of the events:
Grid_Init
Page_Load
NeedDataSource
ItemCommand - this is a problem ++++
Page_PreRender
while normal sequence of the event will be
Grid_Init
Page_Load
ItemCommand
NeedDataSource
Page_PreRender
The repricussions of it is that neither FilterExpression nor SortExpressions are set in NeedDataSource because they set during ItemCommand which fires after NeedDataSource.
I don't want 5000 lines of code, and so my question is how do I troubleshoot it? Apparently, I am not the only one who has this problem.
-Stan
Grid_Init
Page_Load
NeedDataSource
ItemCommand - this is a problem ++++
Page_PreRender
while normal sequence of the event will be
Grid_Init
Page_Load
ItemCommand
NeedDataSource
Page_PreRender
The repricussions of it is that neither FilterExpression nor SortExpressions are set in NeedDataSource because they set during ItemCommand which fires after NeedDataSource.
I don't want 5000 lines of code, and so my question is how do I troubleshoot it? Apparently, I am not the only one who has this problem.
-Stan
0
Hello Stan,
The events sequence you described, this that happens in your case, is expected when the grid ViewState is disabled. To solve the issue, either enable the ViewState back, or on ItemCommand, set the grid DataSource to null and Rebind() to make sure the NeedDataSource event fires after ItemCommand as well.
Greetings,
Iana Tsolova
the Telerik team
The events sequence you described, this that happens in your case, is expected when the grid ViewState is disabled. To solve the issue, either enable the ViewState back, or on ItemCommand, set the grid DataSource to null and Rebind() to make sure the NeedDataSource event fires after ItemCommand as well.
Greetings,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Stan
Top achievements
Rank 1
answered on 18 Apr 2012, 03:14 PM
The problem was caused by ViewState disabled on the page even though grid ViewState was enabled.
-Stan
-Stan