从DataGrid删除不需要的零 [英] To Remove unwanted Zeros from the DataGrid

查看:126
本文介绍了从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 the DefaultValue of the DataColumn of the DataTable might have been set to 0.
Try setting it to DBNull.Value as below
DataSet1.Tables[TableName].Columns[ColumnName].DefaultValue = DBNull.Value;


这篇关于从DataGrid删除不需要的零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆