Select row and those data pass them to another aspx

2

At the moment I only have this idea, when you select a column, the Id is placed in a Label and at the same time it is directed to the other page, dragging the Label3 ( id_cr ), and putting it in another Label on the new page ( Imp.aspx ) to fill a form automatically, here the table that appears in Home.aspx :

Here the data should appear ( Imp.aspx ) or the data of Id is being brought (from the table that is in ( Home.aspx ), and in PageLoad (from Imp.aspx.cs ) load the table of the database, the data should appear here:

    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {

        GridViewRow row = GridView2.SelectedRow;
        Label3.Text = row.Cells[1].Text;
        Response.Redirect("Imp.aspx");

    }

How do I relate the id_cr from page to page? What recommendations would you use? I accept opinions with JavaScript, only that I am more familiar with C #, Thanks!

    
asked by CarlosR93 02.01.2017 в 19:25
source

2 answers

2

You can take the data you like in a session variable, for example, assuming that the id_cr is of type string , initially you can assign it like this:

Session["_id_cr"] = "id_cr";

Now, where you want to recover the value of Session["_id_cr"] is as follows:

string id_cr = Session["_id_cr"].ToString();

Another way, is to send the parameters by means of the Response.Redirect . To assign the variable:

Response.Redirect("Imp.aspx?idcr=ValorDelIdCr");

To recover the value:

string id_cr = Request.QueryString["idcr"];
    
answered by 02.01.2017 в 19:48
1

Thanks! I was able to solve it in the following way:

(Home.aspx)

        GridViewRow row = GridView2.SelectedRow;
        Label3.Text = row.Cells[1].Text;
        String Valor = Label3.Text;
        Response.Redirect("Imp.aspx?valor=" + Valor);

(Imp.aspx)

        String Valor = Request.QueryString["Valor"];
        Label2.Text = Valor;
    
answered by 02.01.2017 в 20:40