Solved

system.format exception-Input string was not in a correct format

Posted on 2009-05-06
2
894 Views
Last Modified: 2012-06-27
I am trying to assign a value from the database to the second column of the data Grid View.Then it is throwing an error.Here is the error.

The same code worled perfectly fine when i tried to assign the values to the first column of the Grid.


For Each row As DataGridViewRow In Gridview1.Rows
                    If Not DBNull.Value.Equals(row.Cells.Item(0).Value) Then
row.Cells.Item(1).Value =abcdef
 Next

Open in new window

0
Comment
Question by:yuvaratna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
Aanvik earned 500 total points
ID: 24318179
Can you try this?

row.Cells.Item(1).Value = "abcdef"

For Each row As DataGridViewRow In Gridview1.Rows
                    If Not DBNull.Value.Equals(row.Cells.Item(0).Value) Then
             row.Cells.Item(1).Value = "abcdef"
 Next

Open in new window

0
 

Author Comment

by:yuvaratna
ID: 24318258
Nope! that didnt work
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question