I have a WebDataGrid which includes a checkbox. The rows of the grid are dependant on a selection from a drop down list, so I repopulate the datasource on the list's SelectedIndexChanged trigger. As long as no checkbox in the grid is checked, this works fine. However, if I check a checkbox I get the error "Requested record cannot be found by key". (See Stack Trace at the end of this post.)
I've tried several things. I added a handler for the grid's OnRowUpdating. However, this error is thrown before that function is reached. (I put a breakpoint in and deliberately selected a record that would appear again after I changed the drop down list selection. The breakpoint was hit in that case, and I did not get the error. When I selected an option that did not include that record, the breakpoint was NOT hit before the error was thrown.)
I set the Behavior Core's AutoCRUD to false, made no difference at all.
I added a function for OnPreRender and only cleared and reset the datasource in that function. Still got the error.
Help! I've been working on this for 2 days and I'm stuck. I actually don't want the grid to try to update the datasource AT ALL. (Like, EVER. The checkbox is used solely to determine which values to include when running a report, NOT to update the database in any way, shape or form.) Any way to get it to not even try???
[MissingRecordException: Requested record cannot be found by key.Common Causes:- The data key field(s) is being edited causing the record not to be found when trying to update.- Not rebinding the grid when there are updates to be committed (assuming DataViewState is disabled in this case) – for instance if the grid is bound on !IsPostback.- While a user is editing a particular row in the grid, another user deletes the record from the database. On posting back, the grid is rebound to the updated datasource which no longer contains the record, resulting in the exception.- Changing completely or filtering the grid’s datasource before all CRUD operations are carried out – this is quite common when using other controls on the page to do this . This is partly due to the fact that control events such as SelectedIndexChanged for a dropdownlist or Click for a button fire before the updating events. Changing the grid’s source should in such cases be delayed for later (PreRender).] Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) +1037 Infragistics.Web.UI.GridControls.GridBehavior.Infragistics.Web.UI.GridControls.IGridBehavior.OnAction(String actionType, Object id, Object value, Object tag) +48 Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) +1312 Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() +226 Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() +78 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent() +37 System.Web.UI.Page.RaiseChangedEvents() +132 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1644
Hello allison_musche,
Thank you for posting in the community.
WebDataGrid's CRUD implementation relies on all the records which may have been edited/added or deleted to be available in the datasource when CRUD operations are handled. I.e. if row 1 from datasource A has been edited,then the grid should be bound to the same datasource A at the time when RowUpdating is raised.
In this scenario, the SelectedIndexChanged event of the dropdownlist used to select the grid's datasource would be fired before the grid's CRUD events. Therefore, if the datasource is changed at that point, the grid would look for the record to update in the new datasource and, when it is not found, the "Requested record cannot be found" exception would be raised.
To resolve this issue, I would suggest holding a reference to thecurrentgrid datasource, for instance in a Session variable. On each Page_Load, the grid can be rebound to the same datasource to which it was bound last (on a previous postback), to ensure that grid updates can be handled accordingly. On the dropdownlist's SelectedIndexChanged the grid isnotbound to the new datasource. Instead, the grid is rebound to the new datasource (and the current datasource session variable is updated) at thePreRenderstage, when all CRUD operations have already been handled.
Hope this helps. Please do not hesitate to contact me if you have any questions.
Is there no way to get it to NOT try to update the datasource? I've found references to turning off AutoCRUD and doing it manually, but even when I changed teh AutoCRUD setting to false it still tried to update automatically. I can try your workaround - I already have one session variable for the datasource, as I have to rebind on every postback. I suppose I can add another but it feels clunky to have an "OldDataSource" who's only purpose is to be ignored and keep WebDataGrid from throwing errors.
Hello Allison_musche,
Thank you for your reply.
The "Requested record" exception occurs before the CRUD events are raised as the grid firstly needs to lookup the records which have been edited in order to be able to pass them to the CRUD handlers.
There are a couple of alternative approaches which may interest you in this scenario :
- If the only "edited" column is a checkbox column, a templated column with checkboxes in the item templates would allow you to check specific rows and at the same time the CRUD events would not be raised (as the actual records are not modified, only the templated controls).
- By enablingDataViewStateit is possible to have the grid lookup for the updated records in the viewstate (where the record data is stored). However, there are a couple of important consideration in this case is that if any additional serverside events are enabled on the grid (paging, sorting, filtering, etc) - the grid would still require rebinding on the respective behavior's event. In addition to that in this case the grid would still need to be rebound to the new datasource after the CRUD operations (however as the datas is kept in the viewstate remembering the previous datasource would not be needed).
http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=WebDataGrid_Getting_Started_with_WebDataGrid_EnableDataViewState_Property.html
Feel free to contact me if you have any questions.
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
Hi Allison
I am having this nightmare scenario too. All I am doing is hitting enter on the last column in the grid to update the row and it crashes with this error!!!!!!!!!!
Do you folks at infragistics have any idea how much time we absolutely WASTE because your controls are so complicated and tricky to use??????? WASTE!!!!!!!!!!!!!
Gary
2 nightmare on infragistics issues in the same day wasting hours and hours and hours and days and days and days and days?????????????????
Call me or maybe its time to find another vendor after 20 years with you, I cannot put up with much more.
909 631-1017
gary.goodwin@gmail.com
Hi Gary
I absolutely agree with you. I am used to having html fully under my control. I am on a Web Forms contract and the business are insisting on Infrajokestics controls. I have never ever experienced anything like it. We are weeks into a projects and we still dont have a working grid. None of the utility tools works and the licencing is a complete disaster. Our licenced verision is coming up as unlicenced so most of the functionality is disabled. Massive script files coming back at me from the server when the grid renders. Huge waste of time. I currently have 38 post on 1 thread to try and grapple with all the errors I am getting... and I still cant get the grids working dynamically. Auto Crud doesnt work and styling is another disaster. How can anyone take this technology as anything more than a joke. They are trying to help me but because of the extent of the instability, even their developers can only guess at what causes the errors. Every time I ask a question, I have to wait 2 days for a response. I can only hope that this serves as a warning to anyone out there thinking of using this control suite.
Hi,
Now I have the same problem. Do you have a full example (only a checkbox column can be editable) to see how implement this issue?
Regards,
Jordi