protected void Button1_Click(object sender, EventArgs e)
{
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();
}
25
2012
04
查询数据库并绑定到GridView
发布:郑德才博客 | 分类:学习之路 | 评论:0 | 浏览:
相关文章:
【C#、Asp.Net 工具类大全】GridView 绑定数据及操作大全工具类 (2015-6-14 20:58:34)
Asp.Net下GridView合并TemplateField模板列和BoundField绑定列方法 (2013-12-19 18:5:14)
Gridview使用CheckBox全选与单选 (2013-5-22 22:29:38)
GridView和DataGrid相同列合并 (2012-10-18 22:16:4)
Asp.net中GridView非常详细的使用详解GridView无代码分页排序 (2012-8-1 15:3:44)
GridView自定义的模版分页,简单实现 (2012-7-18 7:36:44)
asp.net 关于获取GridView列的值 (2012-7-8 6:52:9)
Asp.Net GridView每条记录前面都有一个多选框,可以实现全选 (2012-5-4 21:21:23)
Asp.Net GridView批量删除数据操作 (2012-4-18 7:54:7)
获取gridview中选中的行,获取选中列表 (2012-4-11 20:40:28)
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。