hi Kevat, Since you are trying to retrieve data from previous page. I think there are more ways to do so.
For exmaple: -
<div>Query String </div>
<div>Session variables</div>
<div>Submit form using Hidden field.
</div>
There are several examples you can search on google.
Suppose you want to pass the INTEGER (state_index) variable from Page1 to Page2 on button click event using QueryString.
To Read the value of "id" in Page2, you should use the below code in the
Page2_Load ()
{
int qstr = (Int) Request.QueryString["id"]; //Now qstr will hold the data from the querystring.
}
Suppose you want to pass the state_index variable from Page1 to Page2 on button click event using Session.
So, store a value inside a session variable as follows.
dilipv
Member
448 Points
72 Posts
Re: Passing data between ASP.net pages
Feb 22, 2008 05:38 AM|LINK
hi Kevat,
Since you are trying to retrieve data from previous page. I think there are more ways to do so.
For exmaple: -
</div>
There are several examples you can search on google.
Suppose you want to pass the INTEGER (state_index) variable from Page1 to Page2 on button click event using QueryString.
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Page2.aspx?id=" + state_index); // QueryString Added to URL
}
To Read the value of "id" in Page2, you should use the below code in the
Page2_Load ()
{
int qstr = (Int) Request.QueryString["id"]; //Now qstr will hold the data from the querystring.
}
Suppose you want to pass the state_index variable from Page1 to Page2 on button click event using Session.
So, store a value inside a session variable as follows.
protected void Button1_Click(object sender, EventArgs e)
{
Session["Index"] = state_index;
Response.Redirect("Page2.aspx");
}
Now, To retrieve the value from Page2 use the below code
Page2_Load ()
{
int i = (Int) session["Index"];
}
Hope this will help you.
Thanks Regards
Dilipv
Programmer
.Net Consulting
If this post is answer for your query then don't forget to mark as an answer.