如何在GridView中添加过滤器? [英] How to add filter in gridview?

查看:114
本文介绍了如何在GridView中添加过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想在gridview.i中添加下拉过滤器,但用Google搜索了很多,但我得到的是所有这些都使用单个表或列是在代码本身中生成的.

在我的情况下,从下拉列表中选择表名称时表会更改.因此我无法打开自动生成的列.

例如.

输入表格名称:电影/用户

gridview包含:具有不同类别的电影列表或具有不同列的用户列表.

请帮我.

网点大师们寄予厚望:
SAKryukov
约翰·西蒙斯
撒拉雅
OriginalGriff
Abhinav S
Mika Wendelius

hello All,
I want to add dropdown filter in gridview.i googled a lot but all i got is that all are using a single table or columns are generated in code itself.

in my case,tables are changed on selecting the table name from a dropdownlist.so i can not make auto-generated-column on.

eg.

enter table name: movie/user

gridview contains : list of movies with different category or list of user with different columns.

plz help me.

have a lot of hope from you dot net masters:
SAKryukov
John Simmons
thatraja
OriginalGriff
Abhinav S
Mika Wendelius

推荐答案

尝试使用此网址........................ http://forums.asp.net/t/1635589.aspx/1 [
Try this url.....................http://forums.asp.net/t/1635589.aspx/1[^]




您可以在aspx代码页中添加DropDown:

Hi ,

you can add DropDown in aspx code page:

<asp:dropdownlist id="DropDownList1" runat="server" xmlns:asp="#unknown">AutoPostBack="true" 
       onselectedindexchanged="DropDownList1_SelectedIndexChanged">
   </asp:dropdownlist>



Autopostback属性将其设为true.

在C#代码页



Autopostback attribute make it true.

at C# code page

protected void  DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (DropDownList1.SelectedItem != null )
    {
        string selectedtext = DropDownList1.SelectedItem.Text;
        string selectedValue = DropDownList1.SelectedItem.Value;

        // write your logic for bind gridview as per selected item.
    }
}



请让我知道这对您有帮助.



Please let me know is this helpful to you.


这篇关于如何在GridView中添加过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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