查询数据库并绑定到GridView
{
SqlDataSource sqlSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString,
"SELECT * FROM [tb_ title] WHERE Title like '%@TitName%' and Info like '%@TeaName%';");
ControlParameter country = new ControlParameter();
country.Name = "Title";
country.Type = TypeCode.String;
country.ControlID = "TitleText";
country.PropertyName = "SelectedValue";
sqlSource.SelectParameters.Add(country);
country.Name = "Info";
country.Type = TypeCode.String;
country.ControlID = "InfoText";
country.PropertyName = "SelectedValue";
sqlSource.SelectParameters.Add(country);
Page.Controls.Add(sqlSource);
GridView1.DataSource = sqlSource;
GridView1.DataBind();
}