I have a webdatatree control based on which the data for my webhierarchicaldatagrid is bound with.
Say I made some changes in the grid and without submitting the page I click on another node of the tree I need to confirm with the user for the unsaved changes and if the user opts to undo the changes, I get the following error.
Exception Type: Infragistics.Web.UI.GridControls.MissingRecordException
Message:
========
Requested record cannot be found by key.
Stack Trace:
============
at Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag)
at Infragistics.Web.UI.GridControls.GridBehavior.Infragistics.Web.UI.GridControls.IGridBehavior.OnAction(String actionType, Object id, Object value, Object tag)
at Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state)
at Infragistics.Web.UI.GridControls.ContainerGridBot.LoadAdditionalClientState(Object state)
at Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent()
at Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent()
at Infragistics.Web.UI.GridControls.ContainerGrid.RaisePostDataChangedEvent()
at System.Web.UI.Page.RaiseChangedEvents()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)InnerException 1
My code
Sys.Application.add_init(application_init);
function application_init() { var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(prm_initializeRequest);}
function application_init() {
var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(prm_initializeRequest);}
function prm_initializeRequest(sender, args) { try { //var tree = $find("<%= wdtTree.ClientID %>"); var grid = $find("<%= whdgGrid.ClientID %>"); var hasChanges = false; if (grid != null) { if (grid.get_gridView()._actionList._count > 0) { hasChanges = true; } } if (sender._postBackSettings.sourceElement.id == "<%= wdtTree.ClientID %>" && hasChanges==true) { grid.get_gridView().get_behaviors().get_editingCore().clearBatchUpdates(); //grid.get_gridView()._actionList.clear(); } else if (sender._postBackSettings.sourceElement.id != '<%= btnSubmit.ClientID %>' && hasChanges ==true) { var submitChanges = confirm("Well allocation data has been modified do you want to review and save the changes?"); if (!submitChanges) grid.get_gridView().get_behaviors().get_editingCore().clearBatchUpdates(); else { alert("Please click on submit button to save changes."); args.set_cancel(true); } } } catch (e) {} }
thanks
Hello Lily,
Thank you for posting in our community. There are forum threads regarding this issue. Please visit the following links:http://blogs.infragistics.com/forums/t/51608.aspx
http://forums.infragistics.com/forums/p/61688/312347.aspx
http://community.infragistics.com/forums/t/47648.aspx
http://news.infragistics.com/forums/t/58797.aspx
http://news.infragistics.com/forums/p/65467/331717.aspx
http://news.infragistics.com/forums/p/65291/330871.aspx
http://blogs.infragistics.com/forums/p/63501/321876.aspx#321876
http://blogs.infragistics.com/forums/p/62962/318870.aspx
From the small code snippets I could not determine where the issue comes from. I will need more detailed information like what is your datasource. What are your update/delete querries WHDG mark up.
Hello Lily,Please let me know what is your progress with this issue. Did you manage to resolve it?
The following link has a workaround which helped me resolve my issue.http://es.infragistics.com/community/forums/t/72259.aspx
I had to add the following:
function CallProxy() { document.getElementById('<%=RadioButtonAutoPostbackProxy.ClientID%>').click(); }
I had to update my RadioButtonList from, <asp:RadioButtonList ID="rblOptions" runat="server" RepeatDirection="Horizontal" CssClass="RadioButtonWidth" AppendDataBoundItems="false" AutoPostBack="True" OnSelectedIndexChanged="rbl_SelectedIndexChanged" />to, <asp:RadioButtonList ID="rblOptions" runat="server" RepeatDirection="Horizontal" CssClass="RadioButtonWidth" AppendDataBoundItems="false" AutoPostBack="false" />
I then added a proxy button
<asp:Button ID="RadioButtonAutoPostbackProxy" runat="server" Text="Proxy" OnClick="RadioButtonAutoPostbackProxy_Click" Style="display:none;" />
In my code behind, I added the following, (this is because I am programatically creating the radio button list)
foreach (ListItem li in rblOptions.Items) { li.Attributes.Add("onclick", "CallProxy()"); }
The onclick is simple, as it just re-binds my WebDataGrid:
protected void RadioButtonAutoPostbackProxy_Click(object sender, EventArgs e) { DataBindGrid(); }
Hopefully this helps someone, and saves them the headache of going thru a dozen other irrelevant posts.
Server Error in '/' Application. --------------------------------------------------------------------------------
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Infragistics.Web.UI.GridControls.MissingRecordException: Requested record cannot be found by key.
Please explain the above exception, in your own words. I would like to understand what is actually happens, when one receives the error above.
I have a webdatagrid, with the following -
ig:webdatagrid DataKeyFields="ID" EnableDataViewState="True" EnableViewState="True" EnableAjax="true" OnRowUpdating="grid_RowUpdating"
EditingCore Enabled="true" BatchUpdating="false" AutoCRUD="false"
CellEditingClientEvents ExitedEditMode="ExitedEditMode"
function ExitedEditMode(sender, eventArgs) { var grid = eventArgs._cell.get_grid();
var editingCore = grid.get_behaviors().get_editingCore();
editingCore.commit();}
protected void wgExistingWebContent_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e){ UpdateDatabase(); DataBindGrid();}
private void DataBindGrid(){ webdatagrid.DataSource = getdata(rblOptions.SelectedValue); webdatagrid.DataBind();}
protected void rblOptions_SelectedIndexChanged(object sender, EventArgs e){ DataBindContentGrid();}
Once I have updated my cell, when I click on the radio button... and change my datasource, I get the exception [Requested record cannot be found by key].
Nikifor, the links you have provided are not really relevant.