rfgraham
asked on
Message box for empty DataGridView vb.net 2005
My DataGridView is populated when a search for customer records is done. If I can't find any customer records with a last name starting with "gra" then the DataGridView doesn't get populated with records. What I want to do is create a message if the DataGridView is Empty. What would the code be if the DataGridView is Empty?
Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click
'DATAGRID MULTIPLE RESULTS LIST
Dim MySQLConnection As String = My.Settings.dbConnection
Dim dbConnection As New SqlConnection
dbConnection.ConnectionString = MySQLConnection
Dim bsPatients As BindingSource
bsPatients = New BindingSource
dbConnection.Open()
Dim noRecord As Integer
noRecord = 0
Dim strSQL As String = "SELECT FirstName, LastName, DOB, CustomerID FROM Customer WHERE LastName LIKE '" & LastName.Text & "%' ORDER BY FirstName"
Dim myDA As SqlDataAdapter = New SqlDataAdapter(strSQL, dbConnection)
Dim myPatient As DataTable = New DataTable
myDA.Fill(myPatient)
bsPatients.DataSource = myPatient
DataGridView1.DataSource = bsPatients
dbConnection.Close()
dbConnection = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
Please ignore
If txtCardNumber.Text & "" Then in the above code.Just use the javascript code to give a alert message.
Please ignore
If txtCardNumber.Text & "" Then in the above code.Just use the javascript code to give a alert message.
Open in new window