void BindData1() { ClassDistrict d = new ClassDistrict(); DataTable dt = d.GetDistrictSearch(txtSearchDistrictID.Text, txtSearchDistrictTH.Text, txtSearchDistrictEN.Text, txtSearchAmphurID.Text, txtSearchProvinceID.Text, txtSearchPostCode.Text, txtSearchNote.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void btnSearchDistrict_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchDistrictID.Text) && string.IsNullOrEmpty(txtSearchDistrictTH.Text) && string.IsNullOrEmpty(txtSearchDistrictEN.Text) && string.IsNullOrEmpty(txtSearchAmphurID.Text) && string.IsNullOrEmpty(txtSearchProvinceID.Text) && string.IsNullOrEmpty(txtSearchPostCode.Text) && string.IsNullOrEmpty(txtSearchNote.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { ClassDistrict d = new ClassDistrict(); DataTable dt = d.GetDistrictSearch(txtSearchDistrictID.Text, txtSearchDistrictTH.Text, txtSearchDistrictEN.Text, txtSearchAmphurID.Text, txtSearchProvinceID.Text, txtSearchPostCode.Text, txtSearchNote.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); } }