public void ShowSearchResult() { string content = Request.QueryString["searchContent"]; DataTable dt = new DataTable(); dt = bus.SearchProduct(content); DataListSearch.DataSource = dt; DataListSearch.DataBind(); if (dt.Rows.Count > 0) { lbSearchResult.Text = (dt.Rows.Count).ToString(); } else { lbSearchResult.Text = (dt.Rows.Count).ToString(); Response.Write("<script>alert('Không tìm thấy sản phẩm phù hợp!')</script>"); } }
private void bind() { co.connect(); string value = Session["search"].ToString(); string str = "select * from maintable where title like '%" + value + "%' OR category like '%" + value + "%' OR albummovie like '%" + value + "%' OR singer like '%" + value + "%' "; SqlCommand cmd = new SqlCommand(str, co.con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { DataListSearch.Visible = true; DataListSearch.DataSource = ds.Tables[0]; DataListSearch.DataBind(); //Response.Redirect("home.aspx"); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Data Not Found');", true); DataListSearch.Visible = false; } }