如果搜索没有匹配的单词,如何显示消息框。 [英] How to show message box if no matching word is search.

查看:63
本文介绍了如果搜索没有匹配的单词,如何显示消息框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我创建了一个搜索,我希望有一条弹出消息,如果用户搜索单词不存在,则会告诉用户没有找到记录。继承我的搜索代码。 btw伙计这是asp vb



我尝试过:



Dim searchword As String

searchword =select * from tblstudinfo where(studentid like'%+ searchtxt.Text.ToString())

SqlDataSource1.SelectCommand = searchword

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

推荐答案

使用 SqlDataSource.Selected事件 [ ^ ]及其中一个参数 SqlDataSourceStatusEventArgs [ ^ ]如:

Make use of SqlDataSource.Selected Event[^] and one of its arguments SqlDataSourceStatusEventArgs[^] such like:
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



最后但并非最不重要的,你应该学习使用带有SqlDataSource控件的参数 [ ^ ]由于 SQL注入。 [ ^ ]


这篇关于如果搜索没有匹配的单词,如何显示消息框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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