I left some code out for brevity...
int id = Convert.ToInt32(Page.RouteData.Values[\"id\"]); var q = db.Categories.SingleOrDefault(x => x.categoryID == id);
Because your are trying to make the ternary operator evaluate to either an int (0) or a string (id.ToString()). Replace the 0 with "0".
0
id.ToString()
"0"