public void bindchildgrd() { Grd.DataSource = ViewState["dt"] as DataTable; Grd.DataBind(); Grd1.DataSource = ViewState["dt1"] as DataTable; Grd1.DataBind(); }
void Grd1p_load() { if (string.IsNullOrEmpty(filtr_name.Text) && string.IsNullOrEmpty(filtr_code.Text) && string.IsNullOrEmpty(filter_brand.Text)) { query = string.Empty; } else if (!string.IsNullOrEmpty(filtr_name.Text) && string.IsNullOrEmpty(filtr_code.Text) && string.IsNullOrEmpty(filter_brand.Text)) { query = "where name like N'%" + filtr_name.Text + "%'"; } else if (string.IsNullOrEmpty(filtr_name.Text) && !string.IsNullOrEmpty(filtr_code.Text) && string.IsNullOrEmpty(filter_brand.Text)) { query = "where product_code like N'%" + filtr_code.Text + "%'"; } else if (string.IsNullOrEmpty(filtr_name.Text) && string.IsNullOrEmpty(filtr_code.Text) && !string.IsNullOrEmpty(filter_brand.Text)) { query = "where comment like N'%" + filter_brand.Text + "%'"; } else if (!string.IsNullOrEmpty(filtr_name.Text) && string.IsNullOrEmpty(filtr_code.Text) && !string.IsNullOrEmpty(filter_brand.Text)) { query = "where name like N'%" + filtr_name.Text + "%' AND comment like N'%" + filter_brand.Text + "%'"; } else if (!string.IsNullOrEmpty(filtr_name.Text) && !string.IsNullOrEmpty(filtr_code.Text) && string.IsNullOrEmpty(filter_brand.Text)) { query = "where name like N'%" + filtr_name.Text + "%' AND product_code like N'%" + filtr_code.Text + "%' "; } SqlDataAdapter da = new SqlDataAdapter(@"select * from goods " + query + " ", con); DataTable dt = new DataTable(); da.Fill(dt); Grd1.DataSource = dt; Grd1.DataBind(); }
protected void btnCancel_Click(object sender, EventArgs e) { Grd1.DataSource = null; Grd1.DataBind(); }