如何在文本框中使用“否"或“名称"搜索名称? [英] How to search a name using either no or name in textbox.?

查看:58
本文介绍了如何在文本框中使用“否"或“名称"搜索名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如何在文本框中使用"no"或"name"来搜索名称?.


例如,

Emp.Id Emp.Name
------ --------
D101拉贾
1230 Raghu


如果我在文本框中输入"D101",则该文本框应同时获取否"和名称,如D101-Raja.

如果我输入"Ra",则文本框中应同时提取raja和Raghu.

这是我想在带有ASP.NEt文本框的Ajax控件中使用的..

Hi,

How to search a name using like no or name in text box..?


For example,

Emp.Id Emp.Name
------ --------
D101 Raja
1230 Raghu


If i type "D101" in the text box, the text box should fetch both no and name like D101-Raja.
Or
If i enter "Ra", the text box should fetch both raja and Raghu.

This is i want to use in ajax control with ASP.NEt Text box..

How to do this...?

推荐答案

在您的txtbox_selectedIndexChanged事件中,调用以下函数

In ur txtbox_selectedIndexChanged event call the following function

public sub getData()
dim dbconn,sql,dbcomm
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
data source=" & server.mappath("northwind.mdb"))
dbconn.Open()
sql="SELECT CUSTNUM,CUSTNAME,CUSTACTIVE FROM customers where CUSTACTIVE <> 'I'"
        If txtNum.Text <> 0 Then
            sql= sql & " AND CUSTNUM LIKE '" & txtNum.Text & "%'"
        End If
        If txtName.Text <> 0 Then
            sql= sql & " AND CUSTNAME LIKE '" & txtName.Text & "%'"
        End If      
dbcomm=New OleDbCommand(sql,dbconn)
end sub


从中获取数据后,在程序中使用它


After getting data from it use it in ur program


u可以将SLQ Like运算符与''%''放在


查看此链接将对您有所帮助

http://www.w3schools.com/sql/sql_like.asp [
u can use SLQ Like operator with ''%'' placing


check out this link it will help u

http://www.w3schools.com/sql/sql_like.asp[^]


它简单地使用autopostback =true并启动事件ontextchanged并使用带有类似关键字的sql查询
it simple use autopostback =true and fire the event ontextchanged and use sql query with like keyword


这篇关于如何在文本框中使用“否"或“名称"搜索名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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