cgcmq
asked on
Convert Querystring to Int
I need to receive a querystring, convert it to an integer and then pass it as a parameter to a stored procedure. I have tried:
ID = int.Parse(Request.QueryStr ing["ID"]) ;
int ID = int.Parse(Request.QueryStr ing["ID"]) ;
int ID = int.Parse(HttpContext.Curr ent.Reques t.QueryStr ing["ID"]) ;
In each case the application returns an error that the data type could not be converted.
ID = int.Parse(Request.QueryStr
int ID = int.Parse(Request.QueryStr
int ID = int.Parse(HttpContext.Curr
In each case the application returns an error that the data type could not be converted.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Perhaps the following would work:
int ID = Convert.ToInt32(Request.Qu eryString. Get("ID")) ;
int ID = Convert.ToInt32(Request.Qu
ASKER
I love it when the answer is so easy.
ID = int.Parse(Request.QueryStr ing["ID"]) .ToString( );
ID = int.Parse(Request.QueryStr
as you are again converting the stuff back to ToString() just use
ID = Request.QueryString["ID"]. ToString() ;
ID = Request.QueryString["ID"].
ASKER
It drives me crazy. I looked at 3 different references and non of them mentioned that.
I think that I am going to go back to classic ASP before I lose my mind.
Thanks for the tip.
I think that I am going to go back to classic ASP before I lose my mind.
Thanks for the tip.
parse functions require string format.