三九宝宝网宝宝百科宝宝知识

求教ASP NETc动态操作gridview显示数据库内容

01月07日 编辑 39baobao.com

把sql语句写进SqlDataSource里,下面给VB.net的例子

触发button的点击事件,执行如下代码

Dim sql As String

sql = "select * from tableA where id <>''"

If Not textbox1.text.trim = "" Then

sql = sql & " and colB = '" & textbox1.Text.trim & "'"

End If

sql = sql & " order by id desc"

SqlDataSource7.SelectCommand = sql

GridView1.DataSourceID = "SqlDataSource7"

GridView1.DataBind()

推荐阅读
图文推荐