protected void btnCheckAvalaiblity_Click(object sender, EventArgs e) { string source = (txtSource.Text).ToUpper(); string dest = txtDest.Text.ToUpper(); DateTime date = DateTime.Parse(txtDate.Text); var res = b.CheckFlights(source, dest, date); if (res == null) { string myStringVariable = "Sorry!! There's no Available Flights"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true); } else { GridView1.DataSource = res; GridView1.DataBind(); } }