It seems to be the Linq query in the RowDataBound Event.
Use a
Where condition to filter with the
HeadCode before Select statement.
Something like
var result = from t in data.SUB_HEAD
join x in data.HEADs
on t.head_code equals x.head_code
Where t.head_code=="HeadCodeSelectedFromGrdiviewDataKey" select t;