protected void btnsearch_Click(object sender, EventArgs e) { try { cn.Open(); da = new SqlDataAdapter("select firstname,lastname,username,authority,phoneno,email,Dateofbirth,location from usersdetails where username='******'", cn); da.Fill(ds, "usersdetails"); GridViewofusers.DataSource = ds.Tables[0]; GridViewofusers.DataBind(); if (GridViewofusers.Rows.Count <= 0) { if (Label1.Visible == false || Label1.Visible == true) { Label1.Visible = true; } Label1.Text = "No Records are Found"; } else { Label1.Text = " "; } } catch (Exception ex) { messagelab.Visible = true; messagelab.Text = ex.Message; } finally { cn.Close(); } }
protected void Button2_Click(object sender, EventArgs e) { Label1.Visible = false; try { cn.Open(); da1 = new SqlDataAdapter("select firstname,lastname,username,authority,phoneno,email,Dateofbirth,location from usersdetails ", cn); da1.Fill(ds1, "usersdetails"); GridViewofusers.DataSource = ds1.Tables[0]; GridViewofusers.DataBind(); } catch (Exception ex) { messagelab.Visible = true; messagelab.Text = ex.Message; } finally { cn.Close(); } }