Click here to Skip to main content
15,916,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...?
Posted
Comments
sahabiswarup 10-Nov-11 1:47am    
you may try textbox selectedindex changed.
that will help you to solve your problem.
Anil Honey 206 10-Nov-11 3:24am    
you want to Implement AutoComplete Extender or Normal TextBox.

In ur txtbox_selectedIndexChanged event call the following function

VB
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
 
Share this answer
 
u can use SLQ Like operator with '%' placing


check out this link it will help u

http://www.w3schools.com/sql/sql_like.asp[^]
 
Share this answer
 
it simple use autopostback =true and fire the event ontextchanged and use sql query with like keyword
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900