DataGridView null row
-
I have a DataGridView that has a DataTable set as the data source. When I add a row to the DataTable, it does get added to the grid but it is followed by a null row that sits between the row I just added and the next new row. How do I prevent this bogus row from appearing on the data grid?
-
I have a DataGridView that has a DataTable set as the data source. When I add a row to the DataTable, it does get added to the grid but it is followed by a null row that sits between the row I just added and the next new row. How do I prevent this bogus row from appearing on the data grid?
Often when there is a null row there is an error in the code that is adding rows to the DataTable. I would check that logic. If you would rather apply a hack than a fix to the error you can capture the Data Binding events for the DataGridView and manually remove the null records.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway -
Often when there is a null row there is an error in the code that is adding rows to the DataTable. I would check that logic. If you would rather apply a hack than a fix to the error you can capture the Data Binding events for the DataGridView and manually remove the null records.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest HemingwayYou pointed in a good direction but I still don't know why this is happening. I checked the row added event on the grid and sure enough, when that is getting fired, there is an additional null row in my DataTable which is affecting the grid. When the new row in the DataTable gets committed, the null row disappears from the DataTable but the grid hangs on to it. I can't find any problems with the logic that adds the row to the DataTable so I decided to loop backwards through the grid and get rid of all rows in the DataGrid that do not exist in the DataTable.