Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project I want to take the value in 'v_mem_id' variable to another page. I tried but couldnot succeed. Can any one help me out?

In page1, I used this:

Response.Redirect("addnewprop.aspx?t1=" + v_mem_id);

In page 2, I used this code at pageload:

C#
TextBox5.Text = Request.QueryString["t1"];
      v_mem_id = Convert.ToInt32(TextBox5.ToString());


In page 2 I have declared- static int v_mem_id=0; The value is not getting into page 2 with v_mem_id. Error at page 2 stating 'input string was not in correct format' is appearing.
Posted

1 solution

Perhaps you want to convert the string itself, not the whole text box?
Change:
C#
v_mem_id = Convert.ToInt32(TextBox5.ToString());
To:
C#
v_mem_id = Convert.ToInt32(TextBox5.Text.ToString());



"I get the same error.."

Try this instead:
C#
string s = Request.QueryString["t1"];
TextBox5.Text = s;
v_mem_id = Convert.ToInt32(s);


Bear in mind this is the Page Load event, and the textbox probably hasn't been fully initialised yet.
 
Share this answer
 
v2
Comments
S.Rajendran from Coimbatore 28-Apr-13 6:14am    
I get the same error..
OriginalGriff 28-Apr-13 6:45am    
Answer updated

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