在数据网格视图/发票中添加多个项目 [英] Adding multiple items in Data Grid View / Invoice

查看:87
本文介绍了在数据网格视图/发票中添加多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在Data GridView中显示数据:

I am using following code to show data in Data GridView :

Dim dr As DataRow
        dr = dt.NewRow()
        dr(0) = ItemInvoiceNo
        dr(1) = obj.ReturnString("Select Part_no From Item_Master Where Item_no=" & cmbPartNo.SelectedValue & "")
        dr(2) = Convert.ToString(txtItemType.Text)
        dr(3) = Convert.ToString(txtItemDesc.Text)
        dr(4) = Convert.ToInt32(txtQty.Text)
        dr(5) = Convert.ToInt32(txtRate.Text)
        dr(6) = Convert.ToInt32(txtDisc.Text)
        dr(7) = Convert.ToInt32(txtAmt.Text)

        dt.Rows.Add(dr)
        GridItem.DataSource = dt.DefaultView
        ' cmbItemName.DataBindings.Add("Text", thisDataTable, "Item_name")
        ItemInvoiceNo = ItemInvoiceNo + 1





喜欢我将在单个Data GridView / Invoice中添加多个项目。

我的问题是通过dr = dt.NewRow()这个代码,其中表系统创建新的Row。我问的是这个问题,因为我只想在网格视图中显示字段但系统给出错误输入字符串的格式不正确。不能在Item_type_code列中存储< sylinder>。预期的类型是Int64。

而我没有在表格中保存任何记录。



请帮助我。



Like that i will add multiple items in single Data GridView / Invoice.
My question is through "dr = dt.NewRow()" this code in which table system create new Row. I am asking this question because i just want to show fields in Grid view but system gives an error " Input string was not in a correct format.Couldn''t store <sylinder> in Item_type_code Column. Expected type is Int64."
whereas I am not saving any record in my tables.

Please help me.

推荐答案

输入字符串的格式不正确。无法存储在Item_type_code列中。预期的类型是Int64。

根据错误,Item_type_code应该是Int64类型。但是,你传递字符串:

Input string was not in a correct format.Couldn''t store in Item_type_code Column. Expected type is Int64."
Based on the error, Item_type_code is expected to be of type Int64. But, you are passing string:
dr(2) = Convert.ToString(txtItemType.Text)



检查数据库设计。根据预期的数据类型,相应地传递值。



现在,根据错误,以下内容应解决:


Check the database design. Based on the datatype expected, pass on the value accordingly.

For now, based on error, following should resolve:

dr(2) = Convert.ToInt64(txtItemType.Text)



但是,请确保该值必须是Int64类型。


But, make sure the value has to be of Int64 type.


这篇关于在数据网格视图/发票中添加多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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