How to transfer data from gridview from one page to another page

I have a row in gridview and its last coloumn contians  ACTION hyperlink , which redirects it to another page , i want that the flat number present in gridview also gets transfered to that page.....

Is it possible to perform above task...
Sukesh ShuklaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Naitik GamitSoftware DeveloperCommented:
Yes........It is easy to transfer value from one page to another.
on ACTION hyperlink click event you can send value to another page.

Please provide your ACTION hyperlink click event code.
Tapan PattanaikSenior EngineerCommented:
Hi Sukesh Shukla,


1. First access the value of that row where  ACTION hyperlink is present.
2. Store the value into session.
3. Retrive the value from session varaible from redirected page  .
4.
Example:

If you want to retrieve product id value from a row which is binding to a label inside the gridview on action of delete  button click.

    protected void lnkBtnDelete_Click(object sender, EventArgs e)
    {
   
        ImageButton lnkBtnDelete = sender as ImageButton;
        GridViewRow row = lnkBtnDelete.NamingContainer as GridViewRow;
        Label lblProductId = row.FindControl("lblProductId") as Label;

        if (!string.IsNullOrEmpty(lblProductId.Text.Trim()))
        {
            Session["ProductId"] = lblProductId.Text.Trim();
      
        }
    }

Open in new window


4. How to retrieve the product id in redirected page?
   
  if (Session["ProductId"] != null)
               {
                ProductId= Convert.ToInt32(Session["ProductId"]);
               }

Open in new window


Tapan Pattanaik
iHadiCommented:
Hi

If you are trying to transfer a number (ProductId for example) for a spcific row by clicking the hyperlink in that row you could use querystring.

for each hyperlink in each row, add a parameter to the hyperlink url that represents the number.

For example:

Row 1:
<a href="/ShowProcuct.aspx?ProductId=1">Show Details</a>

Row2:
<a href="/ShowProcuct.aspx?ProductId=1">Show Details</a>

Row 3:
...

And you can retrieve the value of the ProductId from the next page:

string ProductId = Request.QueryString["ProductId"];

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.