Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Conversion from string "" to type 'Integer' is not valid.

Posted on 2006-04-24
2
Medium Priority
?
1,464 Views
Last Modified: 2008-01-09
In an update function for my GridView, I have the following:

Dim intBudget As Integer = CType(gvr.FindControl("txtBudget"), TextBox).Text.Trim()

I get the error: An exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll but was not handled in user code

Additional information: Conversion from string "" to type 'Integer' is not valid.


What's weird is that I've used this format before...not sure why now it's throwing an error in my new application.  I see that I am trying to set an integer to a Text value so how do I CType this to an Integer equivilant?
0
Comment
Question by:dba123
2 Comments
 
LVL 5

Accepted Solution

by:
smoee earned 2000 total points
ID: 16528847
You need to convert your string in your textbox to an integer with something like this:

Dim intBudget As Integer
Try
  intBudget = CType(CType(gvr.FindControl("txtBudget"), TextBox).Text.Trim(),Int32)
Catch
  intBudget = 0
End Try
0
 
LVL 1

Author Comment

by:dba123
ID: 16528935
ahh, I see, didn't know there was yet another param option at the end like that.  Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

571 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