Groups | Blog | Home
all groups > asp.net > february 2006 >

asp.net : Cast QueryString!


Hans Kesting
2/6/2006 2:52:02 PM
[quoted text, click to view]

You can only *cast* to int if you have:
1) a numerical type (double, short, ..)
2) an int boxed as object

Request.QueryString returns a string, which you can convert to an int
with Int32.Parse(..). Note: it will throw an exception if the string
can't be converted to an int. You might want to catch this.

Hans Kesting

Eliyahu Goldin
2/6/2006 3:37:14 PM
intValue = System.Convert.ToInt32 (Request.QueryString["QuestionID"]);

Eliyahu

[quoted text, click to view]

Adam J Knight
2/6/2006 11:05:38 PM
Hi all,

I am having trouble converting query string values to int like so:

intValue = (int) Request.QueryString["QuestionID"];

I keep getting the error, cannot convert string to int...

How can i do this??

Cheers,
Adam

AddThis Social Bookmark Button