Displaying Empty Data with the DetailsView Control

The DetailsView control includes two properties that you can use to display a message when no results are returned from its data source. You can use the EmptyDataText property to display an HTML string, or the EmptyDataTemplate property to display more complicated content.

For example, SqlDataSource in Listing 12.4 does not return a record because no record in the Movies database table has an ID of -1.

Listing 12.4. ShowEmptyDataText.aspx

images

When you open the page in Listing 12.4, the contents of the EmptyDataText property display.

If you need to display more complicated content when no results ...

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.