Look first thing is if no records found it is not a kind of exception.
Still if you want to get it as exception you can through your custom exception as mentioned below :-
Ex :
try
{
if(objDT.Rows.Count <= 0){
throw new Exception("No Records found.");
}else{
}
}
catch (Exception ex)
{
if (ex.Message == "No Records found.")
{
MessageBox.Show("No Records Found", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
OR
You can also directly show the message-box directly at place where you are getting no records in the IF condition satisfaction.
Hope this will definitely be of help, else let me know if any further concerns are there.