Click here to Skip to main content
15,883,873 members

Input string was not in a correct format (at the time of add values in Grid view)

Yogi ,Pune asked:

Open original thread
I want to add items in PO.For that I am using Data Grideview . When user click on add button all the related fields will add in Data Grideview. like that required items will place in PO.I am using following code

VB
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
        ItemInvoiceNo = ItemInvoiceNo + 1


table structure is as follows:
PO Table
Item_PO_No
PO NO
Item No
Unit
Qty
Rate
Disc
Amt

Item Master
Item No
Desc
Part No
Unit
Vat
Item Type code


System give an error after dr(2) = Convert.ToString(txtItemType.Text)

Error:Input string was not in a correct format.Couldn't store <gas> in Item_type_code
Column. Expected type is Int64.
I am unable to find exact problem.Please help me.
Tags: Visual Basic

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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