搜索数据在textchange上使用linq绑定到gridview [英] search data bind to gridview using linq on textchange

查看:78
本文介绍了搜索数据在textchange上使用linq绑定到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

在我的项目中,我有一个文本框.此文本框用于搜索名称.如果我要输入字母,则它将从我的联系表中搜索名称,并将名称,地址,年龄绑定在gridview中.

请任何人知道解决我的问题的解决方案.

hello all

In my project I have an textbox.This textbox is using for searching name.If I will type the letter according to that it will search the name from my contact table and bind the name,address,age in a gridview.

Please anybody know the solution to solve my problem.

thanks in advance!!

推荐答案

尝试类似的事情.

Try something like this.

var query = from r in this.dtContacts.AsEnumerable()
                        where r.Field<string>("Name") == searchname
                        select new{ Age=r["Age"],Address=r["Address"]};



另外,如果要基于在文本框中键入的字母进行搜索,请在LINQ的条件下尝试字符串的StartsWith属性.它应该起作用,请尝试这样做.



Also,if you want to search based on letter typed in textbox,try StartsWith property of string in where condition of LINQ.It should work,havent tried that.


如果使用的是LinqDataSource您可能会找到感兴趣的LinqDataSource.Where和LinqDataSource.WhereParameters.


问候
Espen Harlinn
If you are using a LinqDataSource you will probably find the LinqDataSource.Where and LinqDataSource.WhereParameters of interest.


Regards
Espen Harlinn


这篇关于搜索数据在textchange上使用linq绑定到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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