2016-11-13 5 views
1

私のアプリケーションでは、あるページから別のページにIDを渡す必要があります。セッションを使用しようとしましたが、IDはnullになります。この静的に渡す代わりにIDを次のページに動的に渡す方法

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

答えて

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)); 
関連する問題