想要使用过滤器表达式从gridview中搜索数据 [英] Want to use filter expression to search the data from gridview

查看:50
本文介绍了想要使用过滤器表达式从gridview中搜索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的tableVDC有4000条记录,它在网格视图中显示在aspx页面中。

我还添加了文本框来搜索VDC和搜索按钮。现在,当用户在文本框中输入一些文本并按搜索按钮时,我想从网格中搜索数据。我无法这样做,任何建议都会受到赞赏。

I have the tableVDC with 4000 records and its displayed in aspx page in a grid view.
I have also added the textbox to search the VDC and the search button. Now, I want to search the data from the grid when user input some text in the textbox and press search button. I am not able to do so, any suggestions would be appreciated.

推荐答案

您可以使用简单的LINQ表达式:



首先,您应该尝试通过定义变量或公共属性来获取您在TextBox中键入的文本。



例如

You could use a simple LINQ expression:

First you should try to get the text you typed in your TextBox by defining a variable or a public property.

E.g.
var searchTag = TextBox.Text;









or

private string searchTag
public string SearchTag
{
   get{return this.searchTag;}
   set{this.searchTag = value;}
}







然后,cre吃了一个查询来查找表中匹配的条目

例如




And then, create a query to find the matched entries in your table
E.g.

var searchResults = from r in tableVDC where r.Contains("searchTag") select r;





希望这会有所帮助。



Hope this helps.


这篇关于想要使用过滤器表达式从gridview中搜索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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