Displaying Empty Data

GridView includes two properties that enable you to display content when no results are returned from the GridView control’s data source. You can use either the EmptyDataText property or the EmptyDataTemplate property to handle empty data.

For example, the page in Listing 11.15 contains a movie search form. If you enter a search string that does not match the start of any movie title, the contents of the EmptyDataText property display (see Figure 11.10).

Figure 11.10. Displaying a message when no records match.

image

Listing 11.15. ShowEmptyDataText.aspx

If you use the search form in Listing 11.15 to search for a movie that ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.