• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 923
  • Last Modified:

Convert Request.QueryString to Integer

Hello,

I've

Public IDTopico As Integer

I'm trying to assign the QueryString("id") to the IDTopico. I've tryed like this two ways and I get error messages:

IDTopico = Request.QueryString("id")     (Error:"Conversion from string "'1'" to type 'Integer' is not valid.")

or this

IDTopico = ConvertRequest.QueryString("id")    (Error:"Input string was not in a correct format.")

Can someone help me please?

thanks,

jppinto
0
jppinto
Asked:
jppinto
  • 2
  • 2
3 Solutions
 
tetorvikCommented:
try
int.Parse(Request["id"])
0
 
jppintoAuthor Commented:
I think that your code is not correct. Int.Parse is not valid code!
0
 
tetorvikCommented:
try Integer.Parse that seems to be vb.net equivalent
0
 
BuginatorCommented:
You are using VB?

Dim idString As [String] = Request.QueryString("id").ToString()
Dim idNumber As Integer = Convert.ToInt32(idString )

C# version:
String idString = Request.QueryString["id"].ToString();
int idNumber = Convert.ToInt32(idString);

0
 
jppintoAuthor Commented:
I've solved the problem! I've seen the problem. I was using this:

Response.Redirect("resposta.aspx?id='" & IDTopico &'")  

to send the id to the other page where I was trying to convert something like "'1'" to integer, instead of "1"... sorry for the trouble that I gave you guys. I will assist both of you for the time that you've spent.

Again, thanks.

jppinto
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now