如何动态地将id传递给下一页而不是静态传递

时间:2016-11-13 15:21:51

标签: c# asp.net sql-server

在我的应用程序中,我需要将id从一个页面传递到另一个页面,我尝试使用session但它给我id为null,任何人都可以提供其他方法来执行此操作

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

1 个答案:

答案 0 :(得分:1)

    // 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));