How to pass information between web forms in asp.net

后端 未结 5 1098
面向向阳花
面向向阳花 2021-01-02 14:18

how to send some information from one web form to another web form in asp.net first web form is HumanList.aspx that shows the list of humans in a GridView

5条回答
  •  -上瘾入骨i
    2021-01-02 15:01

    Well, there are many ways to pass information page to page.

    one primary way is by QueryString

    //To Send
    private void submit_Click(object sender, System.EventArgs e)
    {
        string ID = String.Empty;
    
        ID = "192" // Have your ID Here
    
        Response.Redirect("humanEdit.aspx?ID=" + ID );
    }
    
    
    //To Receive
    private void Page_Load(object sender, System.EventArgs e)
    {
       String ID = String.Empty;
       ID=Request.QueryString["name"];
    }
    

    Another Method is Sessions

    //Store your ID from Sending Page
    Session["ID"]= "143"; //Example ID
    
    //To Recieve
    private void Page_Load(object sender, System.EventArgs e)
    {
       String ID = String.Empty;
       ID=Session["ID"].toString();
    }
    

    And there are many other ways too...

提交回复
热议问题