I think if you pass TaskID then you have to use querystrig here ...
I dont unserstand how can you get values in session
YOu can use Querystring as below...
int ID=0;
int.TryParse(Request.QueryString["TaskID"], out ID);
then by this ID you can retrieve data from database with sp.