I'm implementing an inventory program that will view, edit, add, and remove rows from an sql database using the radGridView. The program was started in visual studio 2013 ultimate and did not have this issue. When I opened it in visual studio 2012 ultimate, I suddenly get a data exception sayng "Object reference not set to an instance of an object" when trying to add the first row to the gridview. Through debugging found that it happens in between the useraddingrow event and the useraddedrow event. Once the exception happens, I can correct it by changing the datasource to another table and back again but not before it happens the first time. The exception also happens with empty event handlers (commented out)
Above are the event handlers I comment out while still getting the error.
This is how I assign the data source
The same thing is done on radiobutton checkedchanged to switch between assets and consumables table.
It seems that the data exception HAS to happen before it will let me add a row.
Attached is the error box as well. What doesn't make sense is I did not implement any exception handling that displays the exception message so the program should in theory crash when this message pops up...
Using ADO.NET entity for database access, C#, .net 4.0
I have a build from VS2013 deployed currently with roughly the same setup for the gridview that is not getting the exception.
NOTE: When I switched to VS2012, the gridview was re-added and configured to work with 2012
private void radGridView3_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
{ }
private void radGridView3_UserAddedRow(object sender, GridViewRowEventArgs e)
{
//dbContext.SaveChanges();
}
private void radGridView3_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{ }
private void radGridView3_CellEndEdit(object sender, GridViewCellEventArgs e)
{ }
private void radGridView3_UserDeletedRow(object sender, GridViewRowEventArgs e)
{ }
This is how I assign the data source
MaintenanceEntitiesDB dbContext = new MaintenanceEntitiesDB();
public Form1()
{
InitializeComponent();
// Set initial data source to assets table
dbContext.Assets.Load();
radGridView3.DataSource = dbContext.Assets.Local.ToBindingList();
}
It seems that the data exception HAS to happen before it will let me add a row.
Attached is the error box as well. What doesn't make sense is I did not implement any exception handling that displays the exception message so the program should in theory crash when this message pops up...
Using ADO.NET entity for database access, C#, .net 4.0
I have a build from VS2013 deployed currently with roughly the same setup for the gridview that is not getting the exception.
NOTE: When I switched to VS2012, the gridview was re-added and configured to work with 2012