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
310
Can't Update/Delete Rows - Missing Record Exception
posted

Hello,

 

I am using a WebDataGrid with a SqlDataSource.

The SelectCommand for the SqlDataSource uses a Left Outer Join and when I try to Update/Delete rows in the grid I get the "Missing Record Exception".

Is there a way to overcome this problem?

Here is my code:

 

function WebDataGrid_ExitingEditMode(sender, eventArgs) {

            sender.get_behaviors().get_editingCore().commit();

        }

<asp:SqlDataSource ID="SDSLandmanPay2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

     OldValuesParameterFormatString="original_{0}"

     ConflictDetection="OverwriteChanges"

     SelectCommand="SELECT isnull(ClientLandmanPays.MileageRate, 0) as MileageRate, isnull(ClientLandmanPays.ID,0) as ID,      C.FName + ' ' + C.LName as LandmanName, (SELECT C.FName + ' ' + C.LName + ' - ' + Name FROM Prospects WHERE      ID=ClientLandmanPays.ProspectID) As Name, (c.id) as LandmenID, isnull(ClientLandmanPays.ClientID,0) as ClientID, isnull     (ClientLandmanPays.PayDayRate,0.0) as PayDayRate, isnull(ClientLandmanPays.BillDayRate,0.0) as BillDayRate FROM (Select      FName, LName, ID, UserTypeID from Users WHERE ID in (SELECT LandmenID FROM ClientLandmanPays)) C LEFT OUTER JOIN      ClientLandmanPays ON C.ID=ClientLandmanPays.LandmenID and (ClientLandmanPays.ClientID=@ClientID or      ClientLandmanPays.ClientID is null)"

     DeleteCommand="DELETE FROM [ClientLandmanPays] WHERE [ID] = @original_ID"

     UpdateCommand="UPDATE [ClientLandmanPays] SET [PayDayRate] = @PayDayRate, [BillDayRate] = @BillDayRate, [MileageRate] =      @MileageRate WHERE [ClientLandmanPays.ID] = @original_ID" > 

     <UpdateParameters>

          <asp:Parameter Name="PayDayRate" Type="Decimal" />

          <asp:Parameter Name="BillDayRate" Type="Decimal" />

          <asp:Parameter Name="MileageRate" Type="Decimal" />

          <asp:Parameter Name="original_ID" Type="Int32" />

     </UpdateParameters>

     <DeleteParameters>

          <asp:Parameter Name="original_ID" Type="Int32" />

     </DeleteParameters>

     <SelectParameters>

          <asp:ControlParameter ControlID="LBLClientID" Name="ClientID" Type="Int32" PropertyName="Text" />

     </SelectParameters>

</asp:SqlDataSource>

<ig:WebDataGrid ID="WDGLandmanPay" runat="server" Height="500px" DataKeyFields="ID"

     Width="95%" DataSourceID="SDSLandmanPayDefault"

     AutoGenerateColumns="False">

     <Columns>

          <ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true" DataType="System.Int32">

               <Header Text="ID" />

          </ig:BoundDataField>

          <ig:BoundDataField DataFieldName="Name" Key="Name" Width="35%">

               <Header Text="Name" />

          </ig:BoundDataField>

          <ig:BoundDataField DataFieldName="ClientID" Key="ClientID" Hidden="true" DataType="System.Int32">

               <Header Text="ClientID" />

          </ig:BoundDataField>

          <ig:BoundDataField DataFieldName="PayDayRate" Key="PayDayRate" DataType="System.Decimal"

          Width="25%">

               <Header Text="Pay Day Rate" />

          </ig:BoundDataField>

          <ig:BoundDataField DataFieldName="BillDayRate" Key="BillDayRate" DataType="System.Decimal"

          Width="25%">

               <Header Text="Bill Day Rate" />

          </ig:BoundDataField>

          <ig:BoundDataField DataFieldName="MileageRate" Key="MileageRate" Width="15%">

               <Header Text="Mileage Rate" />

          </ig:BoundDataField>

          <ig:BoundDataField DataFieldName="LandmenID" Key="LandmenID" DataType="System.Int32"

          Hidden="true">

               <Header Text="LandmenID" />

          </ig:BoundDataField>

     </Columns>

     <EditorProviders>

          <ig:CurrencyEditorProvider ID="WebCurrencyEditor1" >

               <EditorControl runat="server" ClientIDMode="Predictable">

               </EditorControl>

          </ig:CurrencyEditorProvider>

     </EditorProviders>

     <Behaviors>

          <ig:EditingCore>

               <Behaviors>

                    <ig:CellEditing>

                         <ColumnSettings>

                              <ig:EditingColumnSetting ColumnKey="ID" ReadOnly="true" />

                              <ig:EditingColumnSetting ColumnKey="Name" ReadOnly="true" />

                              <ig:EditingColumnSetting ColumnKey="ClientID" ReadOnly="true" />

                              <ig:EditingColumnSetting ColumnKey="LandmenID" ReadOnly="true" />

                         </ColumnSettings>

                         <CellEditingClientEvents ExitingEditMode="WebDataGrid_ExitingEditMode" />

                    </ig:CellEditing>

                    <ig:RowDeleting />

               </Behaviors>

          </ig:EditingCore>

          <ig:Selection CellSelectType="Multiple" RowSelectType="Multiple">

          </ig:Selection>

          <ig:RowSelectors RowNumbering="True">

          </ig:RowSelectors>

     </Behaviors>

</ig:WebDataGrid>