1: protected void btnSearch_Click(object sender, EventArgs e)
2: {
3: string connectiongString = WebConfigurationManager.ConnectionStrings["Database"].ConnectionString;
4: SqlConnection con = new SqlConnection(connectiongString);
5: con.Open();
6: SqlCommand cmd = con.CreateCommand();
7: cmd.CommandText = string.Format("select * from DateDemo where 日期='{0}'", this.txtDate.Text);
8:
9: SqlDataAdapter adpt = new SqlDataAdapter();
10: adpt.SelectCommand = cmd;
11: DataSet ds = new DataSet();
12: adpt.Fill(ds);
13: con.Close();
14: this.GridView1.DataSource = ds;
15: this.GridView1.DataBind();
16: }