本文介绍了想要实现一个简单的搜索代表在某些文本框中输入的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..

i我正在使用asp.net和sql数据库,我的问题是



i有5个文本框。 ..



输入UId ...... textBox1

输入名称..... textBox2

进入城市/村庄..... textBox3

输入状态.... TextBox4

输入国家.... TextBox5

按钮用于搜索

(取决于用户在五个文本框中填写了多少条目)

i希望在我的页面中以搜索结果代表的方式实现搜索用户在文本框中输入的数据..(他从搜索匹配的表中选择用户的所有信息)



例如: -

if他输入Name ='''raju''和State =''hariyana''然后结果将是 状态hariyana中的所有Raju

和if他只进入State =''hariyana''然后结果来了 hariyana的所有用户

这种类型的结果我想要



i ho你可以理解我想做什么



实际上我遇到的问题是,如果我使用排列和组合,那么它会变得更复杂,更多的机会出错...

i认为这样做会有一个简单的方法。

请事先建议frnds和thanx ....

Hi to all..
i am using asp.net with sql database and my question is that

i have 5 text boxes...

Enter UId ...... textBox1
Enter Name.....textBox2
Enter City/Village .....textBox3
Enter State ....TextBox4
Enter Country ....TextBox5
button for search
(it depends on user how many entries he fills out of five textboxes)
i want to implement search in my page in a manner that search result come on behalf of data entered in textboxes by User..(he select all information of user from table where search matches)

for eg:-
if he enter Name=''raju'' and State=''hariyana'' then result would be all Raju in state hariyana
and if he only enters State=''hariyana'' then results come is all user of hariyana
this types of result i want

i hope u can understand what i want to do

actually problem i am facing is that if i use permutation and combination for this then it becomes more complex and more chances of mistakes...
i think there will be a simple method for doing this.
Pls suggest frnds and thanx in advance....

推荐答案

protected void Button1_Click(object sender, EventArgs e)
   {
      if(!string.IsNullOrEmpty(textbox1.Text)&&(!string.IsNullOrEmpty(textbox2.Text))&&so on..check for all the text boxes)
        {
           LabelResult.Text="All"+textbox1.Text+"in City/Village"+textbox2.Text+"of state"+textbox3.Text;

        }
      else
          {
            write some code on the else part depending upon your logic
           }

   }



希望它有所帮助..



regrds

Anurag


Hope it helps..

regrds
Anurag


if @userid <> ''
BEGIN
truncate table SecondaryTable
insert into SecondaryTable
select * from PrimaryTable where userId = @userid
truncate table PrimaryTable
insert into PrimaryTable
select * from SecondaryTable
truncate table SecondaryTable
END







- 重复,直到你有非空参数。



这只是一个样本。我们的想法是在没有任何条件的情况下返回所有行,然后根据每个非空参数,从PrimaryTable到SecondaryTable选择记录,清空PrimaryTable并用过滤记录替换记录,清空SecondaryTable。整个过程继续进行所有参数。最后返回PrimaryTable。



试试看它是否对你有用?




--Repeat till you have non-blank parameters.

This is just a sample. The idea is to return all the rows without any condition then based on each non-blank parameter, The records are selected from PrimaryTable to SecondaryTable, Empty PrimaryTable and Replace the records with filtered records, Empty the SecondaryTable. This whole process goes on for all the parameters. In the end return PrimaryTable.

Give it a try and tell if it is of any use for you?


这篇关于想要实现一个简单的搜索代表在某些文本框中输入的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 01:49