-3

I have a query which returns a DataSet. After that I check whether records are available or not. If no records available I want to display error message, exit from the process and redirect to another page. Methods available in below the exiting method should not execute.

Here is the code I have so far.

ds = dba.loadEmpInfo(number, searchType, department);
        string appNumber = "";
        if (ds.Tables[0].Rows.Count > 0)
        {
            appNumber = ds.Tables[0].Rows[0]["Ref_no"].ToString();
            workDS = dba.workExp(appNumber, searchType);
        }
        else
        {
            WebMsgBox.Show("No Record relevant to this app number are available");

        }
Pikoh
  • 7,582
  • 28
  • 53
Mike
  • 1,017
  • 4
  • 19
  • 34

1 Answers1

1

If you want to show Alert message from code behind use below syntax, ScriptManager.RegisterStartupScript(Control control, Type type,string key, string script,bool addScriptTags);

i.e, in the else part
{
ScriptManager.RegisterStartupScript(this, GetType(), "Alert", "alert('No Record relevant to this app number are available!');", true);
// Now Re-direct to the next page as you wish
Response.Redirect("yourPage.aspx");
}