GridView数据过滤 [英] GridView Data Filtering

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

问题描述

如何在asp.net中的文本框按键上过滤gridview日期?

How to filter gridview date on textbox keypress in asp.net ?

推荐答案

You can do it in multiple ways. If you want to use your existing code, you can do it this way

<script type="text/javascript">
    function refreshData() {
        document.getElementById('<%= YourButtonID.ClientID %>').click();
    }
</script>

<asp:TextBox ID="TextBox1" runat="server" onkeypress="refreshData();"></asp:TextBox>


hay,兄弟使用dataview ....



http://stackoverflow.com/questions/3449954/rowfilter-on-a-datatable-to-display-in -a-gridview [ ^ ]

http:// www.dbtutorials.com/display/dataview-datatable-csharp.aspx [ ^ ]

http://www.dotnetfunda.com/codes/code990-gridview-binding-with-dataview-properties.aspx [ ^ ]
hay ,bro use dataview....

http://stackoverflow.com/questions/3449954/rowfilter-on-a-datatable-to-display-in-a-gridview[^]
http://www.dbtutorials.com/display/dataview-datatable-csharp.aspx[^]
http://www.dotnetfunda.com/codes/code990-gridview-binding-with-dataview-properties.aspx[^]


虽然GridView是服务器端控件我建议您重新考虑从客户端按键事件到服务器端TextChanged事件的要求。如果可以,则将OnTextChanged事件处理程序添加到文本框,并将AutoPostback属性设置为true。从服务器端TextChangedEvent处理程序,您可以筛选网格视图。请记住,当您想要切换文本框时,服务器事件将被触发。好处是你不能从客户端(JavaScript)做任何事情。

如果不可能那么接下来我的建议是你去寻求ajax请求而不是GridView服务器端控件,你手动渲染html表和使用javascript keypress事件通过客户端的ajax调用更新它。想想ASP.NET MVC没有任何服务器端控件(gridview,datalist等),那项技术,都需要手动使用html / html助手。
Though GridView is server side control so i suggest you re consider your requirement from client side keypress event to server side TextChanged event. If it can possible then you add OnTextChanged event handler to textbox with set AutoPostback property true. From serverside TextChangedEvent handler you can filter your grid view. Remember when you want to switch the text box that time the server event will fire. The benefit is that you can not do anything from client side(JavaScript).
If it is not possible then next my suggestion is you go for ajax request and instead of GridView serverside control, you manually render html table and update it by ajax call from client side with javascript keypress event. Think like ASP.NET MVC there are no any server side control (gridview,datalist etc), that technology, all need to do manually using html/html helpers.


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

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