just a hint..
may be you have to cast the int to string
i mean this
'~/pages/' + @_Type + 'view.aspx?ID=' + @_ItemID + '&Image='
into this
'~/pages/' + @_Type + 'view.aspx?ID=' + cast(@_ItemID as nvarchar(max)) + '&Image='
and i would cast the IDs that you select too
NOTE : are you sure that the select return a single value?