gridview标题模板中的下拉列表 [英] Dropdownlist in header template of gridview

查看:77
本文介绍了gridview标题模板中的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在gridview的标题模板中有dropdownlist.实际上,它是一种过滤器.由于它现在是子控件,所以这就是为什么要编写以下内容.



I have dropdownlist in my header template of gridview. Actually, its a kind of filter. Since it is a child control now, that''s why wrote the following..

protected void gvDisplayCal_RowDataBound(object sender, GridViewRowEventArgs e)
        { 
           if (e.Row.RowType == DataControlRowType.Header)
             {
              impactFilter =(DropDownList)gvDisplayCal.FindControl("ddlImpact");
             }


        }



在我写的下拉列表的选定的Index Changed属性上,



On selected Index Changed property of dropdownlist I wrote,

protected void ddlImpact_SelectedIndexChanged(object sender, EventArgs e)
        {

            DataTable dt = (DataTable)Cache["dt"];
            if (impactFilter.SelectedItem.Value.ToString() == "All")
            {
                dt.DefaultView.RowFilter = "COUNTRYCOL<>''";
                gvDisplayCal.DataSource = dt;
                gvDisplayCal.DataBind();
            }
            else
            {
                dt.DefaultView.RowFilter = "COL1='" + impactFilter.SelectedItem.Value.ToString() + "'";
                gvDisplayCal.DataSource = dt;
                gvDisplayCal.DataBind();
            }


        }



仅供参考,ddlImpact是我的gridview中的下拉列表,impactFilter是捕获ddlImpact的另一个下拉列表.

我的ImpactFilter似乎为空/空.

我如何使其工作?请提出任何建议?



FYI, ddlImpact is the dropdownlist in my gridview and impactFilter is the another dropdownlist which catches ddlImpact.

My impactFilter appears to be empty/null.

How do I make it working?? Any suggestions please??

推荐答案

正如您所提到的,它为您的gridview提供了一种过滤器,请仔细阅读以下文章,其中介绍了gridview过滤器的创建:
Asp.Net_GridView_Filter [ Excel-like-AutoFilter-Feature-in-ASP. Net-GridView-Control [ Asp.Net_GridView_Filter_Sample [
As you have mentioned that its kind of filter for your gridview, please go through following article which illustrates the creation of gridview filter:
Asp.Net_GridView_Filter[^]
Excel-like-AutoFilter-Feature-in-ASP.Net-GridView-Control[^]

Working Sample:
Asp.Net_GridView_Filter_Sample[^]


这篇关于gridview标题模板中的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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