Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
330
Requested record cannot be found by key undoing grid changes
posted

 

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

 

 

Parents Reply Children
  • 15
    posted in reply to Rob Woodwall

    The following link has a workaround which helped me resolve my issue.

    http://ko.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.