ช่วยดูให้หน่อยครับ ค้นหาจากTaxtbox ได้ แต่ค้นหาจาก DropDownList ไม่ได้ครับ
ไม่ได้เออเร่อนะครับ ต้องเพิ่มคำสั่งอะไรตรงใหนมั้งครับ ขอบคุณล่วงหน้าครับ
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class a : System.Web.UI.Page
{
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
getData();
}
public void getData()
{
SqlDataAdapter adapter = new SqlDataAdapter();
SqlConnection conn = new SqlConnection();
string connect = "Data Source=192.168.7.19,1433;Initial Catalog=sw_db;User ID=sa;Password=a;";
if (conn.State == ConnectionState.Open)
conn.Close();
conn.ConnectionString = connect;
string sql = "select Rp_id,Rp_name,Rp_lastname,Rp_branch,Rp_division,Rp_date,Rp_tel,Rp_device,Rp_symptom,Rp_status from repair_data ";
ds.Clear();
adapter = new SqlDataAdapter(sql, conn);
adapter.Fill(ds, "Table");
ds.Tables["Table"].EndLoadData();
conn.Close();
GridView1.DataSource = ds;
GridView1.DataBind();
}
public void searchData(string keyword)
{
SqlDataAdapter adapter = new SqlDataAdapter();
SqlConnection conn = new SqlConnection();
string connect = "Data Source=192.168.7.19,1433;Initial Catalog=sw_db;User ID=sa;Password=a;";
if (conn.State == ConnectionState.Open)
conn.Close();
conn.ConnectionString = connect;
string sql = "select Rp_id,Rp_name,Rp_lastname,Rp_branch,Rp_division,Rp_date,Rp_tel,Rp_device,Rp_symptom,Rp_status from repair_data where Rp_name like '%"+keyword+"%' ";
ds.Clear();
adapter = new SqlDataAdapter(sql, conn);
adapter.Fill(ds, "Table");
ds.Tables["Table"].EndLoadData();