Grid Panel - LinqDataSource Issue

  1. #1

    Grid Panel - LinqDataSource Issue

    Hello I have a LinqDataSource populating a grid panel, the selection is working properly as well as inserting records.

    However everytime I try to update or delete I get the following error message

    System.Exception: Could not find a row that matches the given keys in the original values stored in ViewState. Ensure that the 'keys' dictionary contains unique key values that correspond to a row returned from the previous Select operation. ---> System.InvalidOperationException: Could not find a row that matches the given keys in the original values stored in ViewState. Ensure that the 'keys' dictionary contains unique key values that correspond to a row returned from the previous Select operation. at System.Web.UI.WebControls.QueryableDataSourceView.GetOriginalValues(IDictionary keys) at System.Web.UI.WebControls.QueryableDataSourceView.BuildDeleteObject(IDictionary keys, IDictionary oldValues, IDictionary`2 validationErrors) at System.Web.UI.WebControls.QueryableDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) at System.Web.UI.WebControls.ContextDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) at System.Web.UI.WebControls.LinqDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) at System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) at Ext.Net.Store.MakeDeletes(IDataSource ds, XmlDocument xml) at Ext.Net.Store.MakeChanges() at Ext.Net.Store.DoSaving(String jsonData, XmlNode callbackParameters) --- End of inner exception stack trace --- at Ext.Net.Store.DoSaving(String jsonData, XmlNode callbackParameters) at Ext.Net.Store.RaiseAjaxPostBackEvent(String eventArgument)
    I've copied my LinqDataSource to a page and used an asp:GridView and I have no issues with any updates or deletes, so I'm sure that the data source is set up properly (primary key is set on the RECID field).

    I'm fairly certain I'm missing something simple, but I've tried everything I could think of. Can anyone help? Thanks in advance

    Datasource

    <asp:LinqDataSource ID="linqMyPriceGroups" runat="server" 
            ContextTypeName="PriceGroupAdministration.DynamicsDataClassesDataContext" 
            TableName="PRICEDISCGROUPs" Where="TERRITORY == @TERRITORY" 
            EnableDelete="True" EnableInsert="True" EnableUpdate="True" 
            oninserting="linqMyPriceGroups_Inserting" 
            onupdating="linqMyPriceGroups_Updating" 
            ondeleting="linqMyPriceGroups_Deleting" StoreOriginalValuesInViewState="true">
            
            <WhereParameters>
                <asp:SessionParameter Name="TERRITORY" SessionField="Territory" 
                    Type="String" />
            </WhereParameters>        
        </asp:LinqDataSource>
    Grid Panel Code

    <ext:GridPanel runat="server" ID="gridMyPriceGroups" AutoExpandColumn="Name" ClicksToEdit="1" >
                                            <Store>
                                                <ext:Store ID="storeMyPriceGroups" runat="server" DataSourceID="linqMyPriceGroups" OnAfterRecordInserted="storeMyPriceGroups_AfterRecordInserted" UseIdConfirmation="true"  >
                                                    <Reader>
                                                        <ext:JsonReader IDProperty="RECID">
                                                            <Fields>
                                                                <ext:RecordField Name="GROUPID" />
                                                                <ext:RecordField Name="NAME" />
                                                                <ext:RecordField Name="TERRITORY" />
                                                                <ext:RecordField Name="CURRENCY" />
                                                                <ext:RecordField Name="RECID" />
                                                            </Fields>
                                                        </ext:JsonReader>
                                                    </Reader>
                                                    <BaseParams>
                                                        <ext:Parameter Name="RECID" Value="#{gridMyPriceGroups}.getSelectionModel().hasSelection() ? #{gridMyPriceGroups}.getSelectionModel().getSelected().id : ''" Mode="Raw" AutoDataBind="true" />                                                
                                                    </BaseParams>                                              
                                                </ext:Store>
                                            </Store>
                                            <SelectionModel>
                                                <ext:RowSelectionModel runat="server" SingleSelect="true"></ext:RowSelectionModel>
                                            </SelectionModel>
                                            <ColumnModel ID="ColumnModel1" runat="server">
                                                <Columns>   
                                                    <ext:Column ColumnID="RECID" DataIndex="RECID" Hidden="true"></ext:Column>                                           
                                                    <ext:Column ColumnID="GroupId" Header="Group Name" DataIndex="GROUPID"  >
                                                        <Editor>
                                                            <ext:TextField ID="TextField1" runat="server">
                                                            </ext:TextField>
                                                           
                                                        </Editor>
                                                        <Renderer Fn="priceGroupRenderer" />                                                    
                                                    </ext:Column>
                                                    <ext:Column ColumnID="Name" Header="Group Description" DataIndex="NAME">
                                                        <Editor>
                                                            <ext:TextField ID="TextField2" runat="server">
                                                            </ext:TextField>
                                                        </Editor>
                                                    </ext:Column>
                                                    <ext:Column ColumnID="Currency" Header="Currency" DataIndex="CURRENCY">
                                                        <Editor>
                                                            <ext:ComboBox runat="server" ForceSelection="true">
                                                                <Items>
                                                                    <ext:ListItem Value="USD" Text="USD" />
                                                                    <ext:ListItem Value="CAD" Text="CAD" />
                                                                </Items>
                                                            </ext:ComboBox>
                                                        </Editor>
                                                    </ext:Column>
                                                </Columns>
                                            </ColumnModel>
                                            <Listeners>
                                                 <BeforeEdit Fn="AllowPriceGroupEdit" />
                                            </Listeners>
                                            <SaveMask Msg="Saving Price Groups" ShowMask="true" />
                                            <LoadMask Msg="Loading Price Groups" ShowMask="true" />
                                            <Buttons>
                                                <ext:Button runat="server" ID="btnSavePriceGroup" Text="Save" Icon="Disk">
                                                    <Listeners>
                                                        <Click Handler="#{gridMyPriceGroups}.save();" />
                                                    </Listeners>
                                                </ext:Button>
                                                <ext:Button ID="btnDeleteZone" runat="server" Text="Delete" Icon="Delete"
                                                    IconCls="icon-delete" >
                                                    <Listeners>
                                                        <Click Handler="#{gridMyPriceGroups}.deleteSelected();" />
                                                    </Listeners>
                                                </ext:Button>
                                                <ext:Button ID="btnInsert" runat="server" Text="Create New" Icon="Add"
                                                    CommandName="" IconCls="icon-add" IDMode="Legacy" >
                                                    <Listeners>
                                                        <Click Handler="#{gridMyPriceGroups}.insertRecord(0, {});#{gridMyPriceGroups}.getView().focusRow(0);#{gridMyPriceGroups}.startEditing(0, 0);" />
                                                    </Listeners>
                                                </ext:Button>
                                            </Buttons>
                                        </ext:GridPanel>
    Last edited by geoffrey.mcgill; Aug 27, 2010 at 10:21 PM. Reason: please use [CODE] tags

Similar Threads

  1. [CLOSED] Grid Panel Grouping Issue
    By jesperhp in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jan 16, 2012, 7:43 AM
  2. Replies: 2
    Last Post: Feb 21, 2011, 6:22 AM
  3. Mask issue on grid panel
    By dan182 in forum 1.x Help
    Replies: 10
    Last Post: Jun 17, 2010, 1:20 PM
  4. [CLOSED] Grid Panel Column Issue
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 07, 2010, 12:01 PM
  5. [CLOSED] Grid Panel Select and Unselect Issue
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 06, 2010, 10:39 AM

Tags for this Thread

Posting Permissions