hello. I've created a page that has a gridview that when you selected a row on it, the data will pass into another page.. the code is this:
1stpage.aspx
.......
..........
|
2ndPage.aspx.cs
..........
protected void Page_Load(object sender, EventArgs e)
{
string strNo = Request.QueryString["no"];
string strDesc = Request.QueryString["desc"];
string strType = Request.QueryString["type"];
string strUsername = Request.QueryString["username"];
Label2.Text = strNo;
Label3.Text = strDesc;
Label9.Text = strType;
Label10.Text = strUsername;
}
...........
|
the passing of data from the gridview into the page of 2nd page worked!
but, I wanted to pass also the data from 2nd page that has been passed from 1st page.
here's my other part of the code in 2ndpage.aspx.cs
........
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("SE_TimeDtLs.aspx?strDesc=" + Server.UrlEncode(Label3.Text) + "&strNo=" + Label2.Text + "&strType=" + Label9.Text + "&strUsername=" + Label10.Text);
}
....... |
SE_TimeDtLs is my 3rd page. There's no output from it..
Where did I go wrong? please help.
thank you so much.
*asp.net
*c#
*web based
Heaven ValenzonaPosted May 21, 2010, 9:48 AM
session["marks"]= txtmarks .Text;
I changed it to :
txtname.Text = Session["name"];
txtmarks.Text = Session["marks"];
because it gives error.
But then again, I cannot passed data to another page./.
please help.. I'm a newbie here sir. Thank you very much
Syed ShakeerPosted May 21, 2010, 2:48 AM
to solve your problem,you have to use the SESSIOn.
look in the following example:-
<asp:GridView runat ="Server" ID="Gridview1" AutoGenerateColumns="False" AutoGenerateSelectButton="True">
<Columns >
<asp:BoundField HeaderText ="Name" DataField ="Name" />
<asp:BoundField HeaderText ="Marks" DataField ="marks" />
Columns>
asp:GridView>
In Gridview Events double Click on SelectedIndexChanged Event and write the below code:
protected void Gridview1_SelectedIndexChanged(object sender, EventArgs e)
{
txtname .Text = Gridview1.SelectedRow.Cells[2].Text;
txtmarks .Text = Gridview1.SelectedRow.Cells[3].Text;
//storing the data in Session
session["name"]=txtname .Text;
session["marks"]= txtmarks .Text;
}
in page2.aspx page
protected void Page_Load(object sender, EventArgs e)
{
label1.Text=session["name"];
label2.Text=session["marks"];
}
in page1.aspx page
protected void Page_Load(object sender, EventArgs e)
{
label1.Text=session["name"];
label2.Text=session["marks"];
}
note:-By using SESSION you can pass data from one to another page untill the user clsoe the browser.