在textchanged事件上过滤Gridview数据 [英] Filter Gridview data on textchanged event

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

问题描述

大家好,
我想过滤在文本框中编写文本时的数据网格视图.我把Autopostback = true放了,但是不起作用.
我想过滤gridview而不丢失文本框中的光标.
当我离开文本框或按Enter,TAB之类的任意键时,网格视图将被过滤.

如何在不失去对文本框的控制的情况下执行此操作.

Hi all,
I want to filter my data grid view on writing text in textbox. i had put Autopostback=true but it is not working.
I wanna filter gridview without losing cursor from textbox.
when i leave textbox or press any keys like enter,TAB then grid view gets filtered.

How to do this without losing control from textbox.

推荐答案

为文本框定义"onkeyup"事件.使用txtB.Attributes.Add("onkeyup", "HandleMethodFilter();");将事件添加到文本框.

现在,使用Javascript定义此方法,并使用AJAX根据过滤器文本取回数据.显示在网格中检索到的数据.
总体而言,您将需要客户端代码,以保持UI不变,集中精力于文本框并更新gridview数据.

试试吧!
Define ''onkeyup'' event for the textbox. Use txtB.Attributes.Add("onkeyup", "HandleMethodFilter();"); to add the event to textbox.

Now, in Javascript, define this method and use AJAX to get back the data based on the filter text. Show the data retrieved in Grid.
Overall, you would need client side code in order to keep the UI as is, keeping focus on textbox and updating gridview data.

Try!


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

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