Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys i created an search and i want to have an popup message that will tell the user like "no records found" if the user search word doesn't exist record. heres my code for searching. btw guys this is asp vb

What I have tried:

Dim searchword As String
searchword = "select * from tblstudinfo where (studentid like '%" + searchtxt.Text.ToString() )"
SqlDataSource1.SelectCommand = searchword
Posted
Updated 28-Dec-16 5:02am
Comments
[no name] 28-Dec-16 10:38am    
Okay and so what is your question?
Member 12919944 28-Dec-16 10:55am    
that my question sir . how ti create a popup window like or error message ?
[no name] 28-Dec-16 12:06pm    
Nowhere in your posting is a question. You would create a popup window by using jquery.
Member 12919944 28-Dec-16 21:41pm    
what plugins of jquery isi it ?

1 solution

Make use of SqlDataSource.Selected Event[^] and one of its arguments SqlDataSourceStatusEventArgs[^] such like:
VB.NET
Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs)

  If e.AffectedRows = 0 Then

     Response.Write("<script language=""javascript""> alert('No match records.');</script>")

  End If

End Sub

Last but not least, you should learn Using Parameters with the SqlDataSource Control[^] instead of injecting parameters into the sql statement directly owing to potential risks posed by SQL injection.[^]
 
Share this answer
 
v9
Comments
Member 12919944 28-Dec-16 11:16am    
selecting or selected ?

Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting

End Sub
Peter Leow 28-Dec-16 11:21am    
The link will tell.
Peter Leow 28-Dec-16 13:39pm    
Added the pop up message box using JavaScript alert.

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