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>
</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 DataFieldName="ClientID" Key="ClientID" Hidden="true" DataType="System.Int32">
<Header Text="ClientID" />
<ig:BoundDataField DataFieldName="PayDayRate" Key="PayDayRate" DataType="System.Decimal"
Width="25%">
<Header Text="Pay Day Rate" />
<ig:BoundDataField DataFieldName="BillDayRate" Key="BillDayRate" DataType="System.Decimal"
<Header Text="Bill Day Rate" />
<ig:BoundDataField DataFieldName="MileageRate" Key="MileageRate" Width="15%">
<Header Text="Mileage Rate" />
<ig:BoundDataField DataFieldName="LandmenID" Key="LandmenID" DataType="System.Int32"
Hidden="true">
<Header Text="LandmenID" />
</Columns>
<EditorProviders>
<ig:CurrencyEditorProvider ID="WebCurrencyEditor1" >
<EditorControl runat="server" ClientIDMode="Predictable">
</EditorControl>
</ig:CurrencyEditorProvider>
</EditorProviders>
<Behaviors>
<ig:EditingCore>
<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>
</ig:WebDataGrid>
The error can be trapped and handled accordinly in the RowUpdated event:
protected void WebDataGrid1_RowUpdated(object sender, RowUpdatedEventArgs e)
{
//this is needed here to suppress the error - in my case i wasn't updating anything but had a checkbox.
e.ExceptionHandled = true;
Hello ksorrell73 ,
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support