Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a session in my page.
in next page i am taking its value into string variable but at one place i have to use it as an int in argument of fn() at page load
how can i do that
i am getting an error- Input string was not in correct format
tell me all possible solutions
please help me soon...
Posted

Well, I guess the error message is quite explanatory. If you try to convert an empty string or something which is not a integer.

You can use TryParse Method anyways:

http://msdn.microsoft.com/en-us/library/system.int32.tryparse.aspx[^]
 
Share this answer
 
Try this

C#
Session["intvalue"] = 2;
int i = int.Parse(Session["intvalue"].ToString());
 
Share this answer
 
Try this in your second page:
C#
int output = 0;
if(Session["intvalue"] !=null)
{
    if(Session["intvalue"] != "")
    {
        int.tryParse(Session["intvalue"].ToString().Trim(), out output);
    }
}
//now output variable contains your integer value.

Now call your function as fn(output).


     --Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900