Solved

vb datagridview with unbound column

Posted on 2013-12-04
3
397 Views
Last Modified: 2013-12-06
I have a datagridview in an application that displays open invoice amounts.  I'm storing data in an MS SQL database.  I created an unbound column for entry of payment amounts against an open invoice.  Upon "submitting" a process is run that applies the payment amount against the open invoice and this works fine.  However, if the user has entered an incorrect payment amount and hits delete to clear the field an exception is thrown, system.formatexception, "input string not in a correct format".  I have not been able to find a way to prevent this from happening.
0
Comment
Question by:GregorySinger
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39698378
The fix will depend on what you're using to determine the field has changed, but it appears you're looking at the value of the unbound field and failing when it's empty.  Trapping for an empty field and bypassing any activity requiring it to be populated would seem like the obvious thing to do.

Is it this unbound field the error refers to?  What are you trying to do with that value when the error occurs?
0
 

Author Comment

by:GregorySinger
ID: 39701069
Yes, it appears to be the origin of the error. I'd like to have a message
Box appear to alert the user. How to trap the error is the issue. TNX.
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39701395
Wrap the code in a Try...CatchTry...Catch.  

Unless the code is inline with the page you can't just pop up a message, but you can throw the error onto the page itself, or have the code e-mail you the error.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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