在我的网站中搜索 [英] search with in a my website

查看:56
本文介绍了在我的网站中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一个带有文本框的搜索按钮..我想在我的网站上搜索产品..当我在文本框中输入产品名称并单击btn go ..时将我重定向到另一页..其中所有类似产品都在我的搜索critaria中..可以通过查询字符串来完成吗??……请帮助

i have a search button in my website with a textbox.. i want to make a search for the products in my website.. when i write a product name in a text box and click on the btn go.. it just redirect me to the other page.. which have all the similer products in which is in my search critaria.. can it b done by query string???... pls help

推荐答案

您的代码无法正常运行,因为您还没有编写出可以正常工作的代码.是的,逻辑上的事情是通过查询字符串传递搜索字符串,以便可以将搜索添加为书签.显然,然后您需要搜索数据库并仅返回匹配的值.
Your code doesn''t work because you''ve not written the code to work, from the sound of it. Yes, the logical thing to do, is to pass the search string via the query string, so that a search can be bookmarked. Then you need to search your DB and return only the values that match, obviously.


这不是问题,只是逻辑上的&业务,用于搜索按钮的操作可以如下所示:
this is not a problem, just logical & business, for search button can be done like below:
Response.Redirect("your_search_page.aspx?ID=" + txtSearch.Text);


因此,在"your_search_page.aspx"中,您可以编写一个Page_Load事件,例如:


so in "your_search_page.aspx", you can write a Page_Load event like:

string query = "select * from Products where ProductID = '" + Request.QueryString["ID"] + "'";
// use SqlDataAdapter to fill data to DataTable and binding to GridView 


注意:我不建议您使用concat字符串创建查询,更好的方法是使用带有参数的查询字符串或存储生产者


notes: i don''t recommend you create an query by concat strings, the better way is use query string with parameter or store producer


在codeproject上有一篇不错的文章:内部站点搜索引擎 [
There is a nice article on codeproject: Internal Site Search Engine[^]


这篇关于在我的网站中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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