DropDownList与DataGridView联动
来源:百度知道 编辑:UC知道 时间:2024/06/28 00:17:58
在改变DropDownList时重新绑定DataGridView
把dropdownlist的autopostback属性改为true
在dropdownlist的SelectIndexchange事件中 绑定Gridview
一条sql语句原来是"select * from tablename"
DropDownList选择了一,则sql语句变为"select * from tablename where id=1"
然后在selectedindexchange事件里面执行这条sql语句!
把返回的结果重新绑定到datagridview里面就可以咯!
很简单啊~
DataGridView绑定的数据源中条件或是什么是DropDownList的某项~
那么在DropDownList的事件selectedindexchange中把条件传给DataGridView~~
看例子吧
http://blog.csdn.net/dqjqsuperboy/archive/2007/05/23/1621792.aspx
就是楼上说的方法 只不过把dropdownlist的autopostback属性改为false就行了