protected void Button1_Click(object sender, EventArgs e) { CustomerMethods cm = new CustomerMethods(); int id = Convert.ToInt32(cid.Text); List <Customerbo> list = new List <Customerbo>(); list = cm.ViewCustomerById(id); GridView1.DataSource = list; if (list.Count() == 0) { Response.Write("<script>alert('Customer Id doesnt exist')</script>"); } GridView1.DataBind(); }