I have a grid that I update manually. The datasource is a datatable that I load in code. There are other events on the page that do not create an update, but do cause the grid to bind with new data. If I have not changed anything in the Grid this works fine. However if I have modified something the postback causes the following
[MissingRecordException: Requested record cannot be found by key.]
Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) +12822 Infragistics.Web.UI.GridControls.GridBehavior.Infragistics.Web.UI.GridControls.IGridBehavior.OnAction(String actionType, Object id, Object value, Object tag) +19 Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) +864 Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() +99 Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() +41 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RaisePostDataChangedEvent() +16 System.Web.UI.Page.RaiseChangedEvents() +132 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1644
AutoCRUD is set to false
EnableDataViewState = true
EnableViewState = true
Can anyone help with this? If AutoCRUD is set to false, what is the EditingCore.OnAction firing for?
Hi azitas,
Can you please share your code for updating the grid? Are you calling the ClearDataSource method? In some cases it may be the cause of this exception. Also, you can check the following threads for more information on the matter:
http://es.infragistics.com/community/forums/p/73762/373058.aspx
http://es.infragistics.com/community/forums/p/77514/393088.aspx#393088
Please let me know if this helps.
I looked at the two links you posted and tried what they suggest and it still does not work
Here is the grid itself:
<
ig:WebDataGrid ID="UserGrid2" runat="server" Width="600px" AutoGenerateColumns="False"
DataKeyFields="User_ID" EnableDataViewState="True" ViewStateMode="Enabled">
<Columns>
<ig:BoundDataField DataFieldName="User_ID" Hidden="True" Key="User_ID">
<Header Text="User_ID" />
</ig:BoundDataField>
<ig:BoundDataField CssClass="leftcol" DataFieldName="FirstName_NM"
Key="FirstName_NM" Width="100px">
<Header Text="First Name" />
<ig:BoundDataField CssClass="leftcol" DataFieldName="LastName_NM"
Key="LastName_NM" Width="100px">
<Header Text="Last Name" />
<ig:UnboundCheckBoxField HeaderCheckBoxMode="Off" HeaderChecked="False"
Key="ShowHasCat" Width="100px">
<Header Text="Category Issue Owner" />
</ig:UnboundCheckBoxField>
<ig:BoundCheckBoxField DataFieldName="HasCat" DataType="System.Boolean"
Key="HasCat" Width="100px" Hidden="True">
</ig:BoundCheckBoxField>
<ig:BoundDataField DataFieldName="CatList" Key="CatList" CssClass="leftcol"
HtmlEncode="False">
<Header Text="User Categories and Locations" />
<ig:BoundCheckBoxField DataFieldName="HasParentCat" DataType="System.Boolean" Hidden="True"
Key="HasParentCat">
<Header Text="BoundColumn_0" />
</Columns>
<Behaviors>
<ig:EditingCore AutoCRUD="False">
<ig:CellEditing>
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="FirstName_NM" ReadOnly="True" />
<ig:EditingColumnSetting ColumnKey="LastName_NM" ReadOnly="True" />
<ig:EditingColumnSetting ColumnKey="HasCat" ReadOnly="True" />
<ig:EditingColumnSetting ColumnKey="CatList" ReadOnly="True" />
</ColumnSettings>
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
<ig:Paging PageSize="30">
</ig:Paging>
</ig:WebDataGrid>
I have one button (BUTTON1) on the page that looks at the grid and updates the data.
I have another control (CONTROL2) on the page that when selected changes the data in the grid (brings back different rows)
The update (BUTTON1) works fine, and the control (CONTROL2) works fine if the grid has not been edited.
However if I click on one of the checkboxes in the grid and then hit CONTROL2 to refresh the grid data, I get the error above.
The code to rebind the grid is below:
Dim dt As DataTable
UserGrid2.ClearDataSource()
dt = SCDB.DB2.ExecSelectSP("GetUsersListSearchForCategory", _ New SqlParameter("@SearchName", SearchName), _ New SqlParameter("@CategoryID", CategoryDDL.SelectedValue), _ New SqlParameter("@EntityID", SearchEntityDDL.SelectedValue))
UserGrid2.DataSource = dt UserGrid2.DataBind()
From the error message it appears that the issue is because ViewState is enabled that the grid is trying to reload the viewstate from before, but because the rows are different now it can't. Is there a way in code to tell the grid to NOT try to reload the view state. Shouldn't this be handled automatically when the Grid is rebound?
Thanks for your help