如何动态传递id到下一页,而不是静态传递

本文关键字:一页 静态 id 何动态 动态 | 更新日期: 2023-09-27 18:17:37

在我的应用程序中,我需要将id从一个页面传递到另一个页面,我尝试使用会话,但它给我id为null,任何人都可以提供其他方法来做到这一点

GridDataItem item = (GridDataItem)e.Item;
string ticketid = item["ID"].Text;
Session["viewID"] = ticketid;
Response.Redirect("View.aspx");

如何动态传递id到下一页,而不是静态传递

    // you check if the item["ID"] is null?
    string ticketid = item["ID"].Text;
    // are you making sure you are not overiding this session variable some place on the page
    Session["viewID"] = ticketid;
// this should get the id on the query string if you don't want to use session.
Response.Redirect(String.Format("View.aspx?ViewID={0}", ticketid));