<p>I need to retrieve a record from a database, display it on a web page (I'm using ASP.NET) but store the ID (primary key) from that record somewhere so I can go back to the database later with that ID (perhaps to do an update).</p>

<p>I know there are probably a few ways to do this, such as storing the ID in ViewState or a hidden field, but what is the best method and what are the reasons I might choose this method over any others?</p>

```
```
Session["MyId"]=myval;
```
```
It would be a little safer and essentially offers the same mechanics as putting it in the viewstate