You could store the ID inside a Session Variable and then call it wherever you want!
var Id1;
var Id2;
Session["FirstID"] = Id1;
Session["SecondID"] = Id2;
If you would like to call it then on another page then you siply do this:
var GetID1 = Convert.ToInt32(Session["FirstID"]);
var GetID2 = Convert.ToInt32(Session["SecondID"]);
The values will be retrieved from the Session and put inside GetID1,GetID2 Variables..
I hope this helps you out!