Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The DataGridView in my form Dynamically saves the data to the Database when a row is completely filled.

And I Can Edit All the rows which is entered,

It is set in a format such that I can add a new Item to the Database enabling the Allow user to addRows,

Everything is working fine,

But I am Getting Unnecessary zeros in the Grid view while Clicking the New row to enter data.

It even Shows the error ending in application - InvalidOperationException was caught - Operation is not valid due to the current state of the object.
Posted

1 solution

One reason could be that the DefaultValue of the DataColumn of the DataTable might have been set to 0.
Try setting it to DBNull.Value as below
C#
DataSet1.Tables[TableName].Columns[ColumnName].DefaultValue = DBNull.Value;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900