从DataGrid删除不需要的零 [英] To Remove unwanted Zeros from the DataGrid
问题描述
我的表单中的DataGridView在完全填充一行后将数据动态保存到数据库中.
我可以编辑所有输入的行,
它的设置格式使我可以向数据库添加新项,从而允许用户添加行,
一切都很好,
但是在单击新建"行以输入数据时,我在网格"视图中得到了不必要的零.
它甚至显示以应用程序结尾的错误-捕获到InvalidOperationException-由于对象的当前状态,操作无效.
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.
推荐答案
一个原因可能是<DataTable
的DataColumn
的c0>已设置为0
.
尝试如下将其设置为DBNull.Value
One reason could be that theDefaultValue
of theDataColumn
of theDataTable
might have been set to0
.
Try setting it toDBNull.Value
as below
DataSet1.Tables[TableName].Columns[ColumnName].DefaultValue = DBNull.Value;
这篇关于从DataGrid删除不需要的零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!