Solved

How can find out if a datalist control has return no results?

Posted on 2008-06-16
1
156 Views
Last Modified: 2013-11-07
I have a datalist control that when some text box fields are filled out, a certain sql statement is executed and a query is populated.  

The results appear when the person hits a search that can populate results.  If there are no results to return i get no action.  I want to be able to check if the datalist rendered results or not.  
Protected Sub Search()
 
        Me.uxSearchDataList.DataSourceID = Me.uxSearchSqlDataSource.ID
 
        Dim sql as string = ""
 
        ..............
 
        Me.uxSearchSqlDataSource.SelectCommand = sql
 
    End Sub
 
    Protected Sub uxSearchButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
 
        Search()
 
    End Sub

Open in new window

0
Comment
Question by:mmedi005
1 Comment
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 21796290
Have you tried counting the datalist items?

        If uxSearchDataList.Items.Count = 0 Then
            'No items in datalist
        End If
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question