I have a RadGrid that is bound to an EntityDataSource. The RadGrid uses an edit form template and two of the controls are bound to Foreign Key tables(objects) of the parent entity object. I have insert and update working. But I get "Object reference not set to an instance of an object" when i perform a delete. Does anyone know why this happens?
Below is a very rough markup of how my code is structured:
Below is a very rough markup of how my code is structured:
| <telerik:radgrid id="myGrid" runat="server" DatasourceID="dsCustomers" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"> |
| <MasterTableView CommandItemDisplay="top" DataSourceId="dsCustomers" DataKeyNames="CustomerId" EditMode="EditForms"> |
| <Columns> |
| <telerik:GridEditCommandColumn ButtonType="ImageButton" EditText="Edit" /> |
| <telerik:GridBoundColumn HeaderText="Title" DataField="Title.Description" /> |
| <telerik:GridBoundColumn HeaderText="Name" DataField="Name" /> |
| <telerik:GridButtonColumn ConfirmText="Delete this Customer?" ConfirmDialogType="Classic" ConfirmTitle="Delete" |
| ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" /> |
| </Columns> |
| <EditFormSettings EditFormType="Template"> |
| <FormTemplate> |
| <table> |
| <tr> |
| <td> |
| <telerik:RadComboBox id="cmbTitle" runat="server" DataSourceID="dsTitles" AppendDataBoundItems="true" |
| DataTextField="Description" DataValueField="Id" SelectedValue='<%# Bind("Title.Id") %>' > |
| <Items><telerik:RadComboBoxItem Value="0" Text="" Selected="true" /></Items> |
| </telerik:RadcomboBox> |
| </td> |
| <td> |
| <telerik:RadTextBox id="txtName" runat="server" Text='<% Bind("Name") %>;' /> |
| </td> </tr> </table> |
| </FormTemplate> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:radgrid> |
| <asp:EntityDataSource ID="dsCustomers" runat="server" ConnectionString="name=CustomerEntities" DefaultContainerName="CustomerEntities" EnableUpdate="true" EnableInsert="true" EnableDelete="true" EntitySetName="Customer" Include="Title" /> |
| <asp:EntityDataSource ID="dsTitles" runat="server" ConnectionString="name=CustomerEntities" DefaultContainerName="CustomerEntities" EntitySetName="Title" /> |