我想通過使用它的名字以顯示從數據庫中的GridView的項目信息在另一頁的內容,我想在GridView到另一個網頁 我想這代碼,,但它並沒有在第一頁按名稱搜索項目,並顯示
protected void Page_Load(object sender, EventArgs e)
{
}
public string txt
{
get
{
// Return the actual name if it is not null.
return TextBox1.Text ?? string.Empty;
}
}
}
在第二頁
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=FATIMAH;Initial Catalog=makeup;Integrated Security=True");
string find = "select * from product where(name like '%' [email protected]+ '%')";
SqlCommand comm = new SqlCommand(find, con);
comm.Parameters.Add("@name", SqlDbType.NChar).Value = txt;
con.Open();
comm.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comm;
DataSet ds = new DataSet();
da.Fill(ds, "name");
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
}