在asp.net webforms中实现搜索功能 [英] Implementing a search function in asp.net webforms

查看:69
本文介绍了在asp.net webforms中实现搜索功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我不确定以前是否已经问过这个问题而且我很抱歉,如果它有,但基本上,我想看看这里是否有人有关于如何构建搜索功能的一些代码或指导/想法何时我键入一个特定的名称或字符,它返回数据,但它只返回它,如果它匹配我输入的,我不确定是否可以这样做,这可能意味着验证,我不是很好,但为了说话的缘故我有一个搜索框和按钮,我输入了计算机科学,它只返回一个名为的模块/主题,如果拼写错误或者它不会返回。



它只搜索名称所在的数据库表,并显示输入的那个,没有别的..可以这样做,如果它匹配,我有以特定方式显示数据的列表视图,也可以复制或使用,因此当搜索匹配时,它会显示模块按钮,就像它在我的另一个页面上一样..



如果您需要任何改进或任何事情让我知道,抱歉,如果这听起来很混乱,但任何帮助都会是非常棒的人们。



我是什么尝试过:



我看过youtube视频,但没有什么能与我想要实现的内容相符:(

解决方案

最简单的方法是使用LIKE关键字



SELECT列FROM MyTable WHERE SomeField LIKE'%hello%'



将搜索SomeField包含Hello的记录。为了做得更好,您还可以查看启用和使用免费在SQL上搜索文本(google上的文章)。下一步是使用像Lucene这样的索引系统为你索引表,你也可以对它执行搜索。 Google如何对sql server使用lucene索引。


Hey folks, I aint sure if this question has been asked before and im sorry if it has but basically, I'm looking to see if anyone here has some code or guidance/idea on how to build a search function where When I type in a "specific" Name or characters, it returns the data but it only returns it if it matches what Ive typed, I aint sure if this can be done and It could mean validation which I aint good with but say for talk sake I had a search box and button and I typed Computer Science, It will only return a module/subject named that, if its spelt wrong or or whatever it wont return.

It will only search the DB table where the names are and display the one that's typed and nothing else.. Can this be done, also if it matches, I have a listview showing data in a specific way, can that be copied or used also so when the search matches it displays the module button like it has on another one of my pages..

If you need any refinement or anything let me know, sorry if it sounds confusing also but any help would be fantastic folks :)

What I have tried:

I have watched youtube videos but nothing matches the specificity of what Im looking to implement :(

解决方案

The simplest way is to use the "LIKE" keyword

SELECT columns FROM MyTable WHERE SomeField LIKE '%hello%'

that will search records where SomeField contains "Hello". To do it better you can also look into enabling and using free text searching on SQL (google for articles on it). The next step would be to use an indexing system like Lucene to index your tables for you and you can execute searches against that too. Google for how to use lucene indexing against sql server.


这篇关于在asp.net webforms中实现搜索功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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