日期:2014-05-17 浏览次数:20456 次
protected void Button1_Click(object sender, EventArgs e)
{
string strsql = "";
strsql = "SELECT * FROM Book WHERE 1=1";
if (this.TextBox1.Text != "")
{
strsql += " AND bookName like'%" + this.TextBox1.Text.ToString() + "%' ";
}
if (this.TextBox2.Text != "")
{
strsql += " AND author like'%" + this.TextBox2.Text.ToString() + "%' ";
}
if (this.TextBox3.Text != "")
{
strsql += " AND ISBN like'%" + this.TextBox3.Text.ToString() + "%' ";
}
Response.Redirect("Default3.aspx?StrWhere=" + strsql);
}
protected void Page_Load(object sender, EventArgs e)
{
string StrWhere = Request["StrWhere"].ToString();
SqlDataSource1.SelectCommand = StrWhere;
GridView1.DataBind();
}