I have a working WebDataGrid that updates and deletes correctly. I added the RowAdding behavior to the WebDataGrid <ig:RowAdding />. Now when I visit the WebDataGrid I Double Click on the grey row and begin adding the data into each cell then hit enter it gives me a very long error.
Asycn request failed
[NullReferenceException]: Object not set to an instance of an object.
Here is my grid
<ig:WebDataGrid ID="dgvStaff" runat="server" Width="100%" EnableDataViewState="True" DataKeyFields="stfGID" ClientIDMode="Static" AutoGenerateColumns="False" onrowsdeleting="dgvStaff_Deleting" onrowupdating="dgvStaff_Updating" onrowadding="dgvStaff_Adding"> <Columns> <ig:BoundDataField DataFieldName="stfGID" Hidden="True" Key="stfGID"> <Header Text="stfGID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="stfFK_cstGID" Hidden="True" Key="stfFK_cstGID"> <Header Text="stfFK_cstGID" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Position" Key="Position"> <Header Text="Position" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="First Name" Key="First Name"> <Header Text="First" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Last Name" Key="Last Name"> <Header Text="Last" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Email" Key="E-Mail"> <Header Text="Email" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Appts" Hidden="True" Key="Appts"> <Header Text="Appointment" /> </ig:BoundDataField> <ig:TemplateDataField Key="Edit"> <Header Text="Delete / Edit" /> <ItemTemplate> <asp:LinkButton ID="Delete" CssClass="sepV_a" OnClientClick="deleteRow(); return false" ToolTip="Delete" runat="server"><i class='splashy-calendar_day_remove'></i></asp:LinkButton> <asp:LinkButton ID="Edit" CssClass="sepV_a" OnClientClick="editRow(); return false" ToolTip="Edit" runat="server"><i class='splashy-calendar_month_edit'></i></asp:LinkButton> </ItemTemplate> </ig:TemplateDataField> </Columns> <Behaviors> <ig:Activation> </ig:Activation> <ig:EditingCore> <Behaviors> <ig:CellEditing> </ig:CellEditing> <ig:RowDeleting /> <ig:RowAdding /> </Behaviors> </ig:EditingCore> <ig:Selection CellClickAction="Row" RowSelectType="Single"> </ig:Selection> </Behaviors> </ig:WebDataGrid>
Any idea what I am missing here?
I was able to find out the issue with help from a colleague. I had a hidden cell that was a primary key. As soon as I gave that cell a value it allowed the row to be created.
protected void dgvStaff_Adding(object sender, Infragistics.Web.UI.GridControls.RowAddingEventArgs e) { // Code stub // call to delete method call
Hashtable newRowValues = e.Values; newRowValues["stfGID"] = System.Guid.NewGuid().ToString();
}
Hi OmegaPrime,
Thanks for sharing your solution with the community.
If you have any other questions, please feel free to contact me.