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
160
MissingRecord exception
posted

Hi all,

I've got a weird problem and i can't figure out what's happening :(

On my web page, i've a webdatagrid with 2 columns (Sequence and ItemCode).  Sequence is readonly.

The DataKeyFields is the sequence field.

Under the WebDataGrid, i've 2 asp buttons (add and delete).

Here is a sample of the Page_Load method :

if (!IsPostBack)

 

{

PreOrderItems = new List<PreOrderItem>();

WebDataGrid_CreateOrder.DataSource = PreOrderItems;

WebDataGrid_CreateOrder.DataBind();

}

else

{

GetData();

 

WebDataGrid_CreateOrder.ClearDataSource();

WebDataGrid_CreateOrder.DataSource = PreOrderItems;

WebDataGrid_CreateOrder.Rows.Clear();

WebDataGrid_CreateOrder.DataBind();

 

}

When i click on the add button, i'm adding one element in my PreOrderItems property which is a IEnumerable<Item> -> PreOrderItems.Add(new Item { Sequence = 1, ItemCode = "Test"});

So when the page is reloaded, the PreOrderItems is binded to the grid with the new item.

Now, when i click on the delete button, i'm removing this element from my PreOrderItems property and then then the PreOrderItems is binded to the grid when the page_load occurs.

But after the event of my delete button i got the following exception :

Requested record cannot be found by key

[MissingRecordException: Requested record cannot be found by key.] Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) +836 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) +670 Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() +202 Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() +73 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent() +34 System.Web.UI.Page.RaiseChangedEvents() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485

It seems that the grid is keeping a reference to my previous databind and it cannot find the deleted item ???

I thought that a simple databind with a new list could be possible but it's not.

Am i doing something wrong ?

Thank you for your help.

 

Btw, it works on Google Chrome but not on Internet Explorer 8.0