Hi, all:
I got the "A critical error has occurred. Object reference not set to an instance of an object." error message, and this is b/c the e.NewObject within the LinqDataSource_Inserting event is null when I am inserting data.
The background of the problem:
I have two grids (both are Telerik RadGrids, which are similar to Gridview, but more powerful). The top one contains contacts, and the bottom one contains one or more notes concerning a selected contact from the top grid. The user can create his own list of note subjects, from which he can choose only one when creating a new note. This list of subjects is bound to a dropdownlist with the markup below:
<asp:DropDownList ID="ddl_subjects" runat="server"
DataSourceID="LinqDS_Subjects" DataTextField="Subject"
DataValueField="SubjectId"
SelectedValue='<%# Bind("SubjectId") %>'
AppendDataBoundItems="True" >
<asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
</asp:DropDownList>
Every time when I create a new note, if I pick one of the bound values, the note inserts fine. But whenever I pick "Select", which has a value of null, to intentionally not assign a subject to the note, I get that error message. I spent hours debugging, but to no avail. So your help is greatly appreciated.
Han