基于DropDowns过滤DataGridView [英] Filtering DataGridView based on DropDowns

查看:96
本文介绍了基于DropDowns过滤DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个,

我有很多DropDown列表,例如客户,产品,状态,SerialNo。等我有一个网格视图。当我选择客户下拉并按下确定按钮然后它应该检索所有数据,其中客户是下拉列表选择项目。类似地,当仅选择产品ddl并按下确定按钮时,它将显示产品是ddl选择项目的所有数据。如果选择了客户和产品,则网格视图将显示客户=客户下拉所选项目的数据。 product = product dropdown selected item。我真正的问题是如何根据不同的条件在gridview中显示不同的数据源。

请帮忙。

解决方案

从这个改编教程: Filter-GridView-Records- using-DropDownList-in-HeaderTemplate-Header-in-ASPNet [ ^ ]


你可以使用gridview控件,不带任何列AutoGenerateColumns如下所示:



 <   asp:gridview     id   =  grdInfo    runat   =  server    autogeneratecolumns   =  True    xmlns:asp   = #unknown >  
< / asp:gridview >





然后使用数据表绑定grideview中的数据并命名数据表中的列


Hi Every one,
I have many DropDown Lists such as customers, products, status, SerialNo. etc And I have one grid view. when i am selecting customer drop down the and press Ok button then it should retrive all the data where customer is the dropdown list selected item. similarly when only product ddl is selected and ok button is pressed then it will show all the data where product is ddl selected item.If both customer and product is selected then the grid view will display the data where customer = customer drop down selected item and product = product dropdown selected item. My real problem is how will i display different data source in a gridview according to different condition.
Please help.

解决方案

Adapt from this tutorial: Filter-GridView-Records-using-DropDownList-in-HeaderTemplate-Header-Row-in-ASPNet[^]


you can use the gridview control with no columns with AutoGenerateColumns is true as the following:

<asp:gridview id="grdInfo" runat="server" autogeneratecolumns="True" xmlns:asp="#unknown">
</asp:gridview>



then bind data inside grideview by using datatable and naming the columns in the datatable.


这篇关于基于DropDowns过滤DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆