页面一
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (this.TextBox1.Text.Trim() == "")
{
Response.Write("<script>alert(/"请输入要搜索的关键字!/");</script>");
} else
{
Session["Sostring"] = this.TextBox1.Text.Trim();
if (this.DropDownList1.SelectedItem.Text == "同学姓名")
{
Response.Redirect("~/windows/so/soXM.aspx");
}
else
{
Response.Redirect("~/windows/so/soXX.aspx");
}
}
页面二
private SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection("server=.;uid=sa;pwd=wojiushixihuan;database=studb");
con.Open();
string str = Session["Sostring"].ToString();
//Response.Write(str);
SqlDataAdapter da = new SqlDataAdapter("select schoolname as 学校,schoolurl as 学校地址 schoolJJ as 学校简介 from School where schoolname like '%" + str + "%'", con);
DataSet ds = new DataSet();
da.Fill(ds, "users");
if (ds.Tables["users"].Rows.Count > 0)
{
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
}
else
{
//this.GridView1.EmptyDataText = "ovjjdsdfsd";
this.GridView1.Visible = false;
this.Label1.Visible = true;
}
}