Do you need those data where DeleteId is null? If not, you could add a WHERE statement like
WHERE ContractItems.DeletedId is not null
before the
Group By
clause.
But I have some doubts... Is ClientId also a number - and the TextBox ClientId contains other characters?
You could replace the line with e.g.
Program.Connection.AddParameter ("@ClientID", Convert.ToInt32(ClientID.Text));