Asp.net repeater empty data template


















AddAt Controls. Header: x. Footer: x. Xavier J Xavier J 4, 1 1 gold badge 12 12 silver badges 25 25 bronze badges. Nitin Singh Nitin Singh 1 1 silver badge 8 8 bronze badges. ToString , " records. Scott Scott 1. On the basis of answer n. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Now change the query so that it returns empty data. On running the application, you would see the following:. Now this display is not elegant enough to inform the user that there is no data, right? So let us see how to display a message in the Repeater control when there is no data present. Now add an ItemDataBound event to the Repeater.

In the code behind, write the following code:. FindControl "lblEmptyData" ;. If Repeater1. Footer Then. FindControl "lblEmptyData" , Label. End If. End Sub. The code checks if the Repeater has items in it.

If the items count is less than 1, the code uses the FindControl to locate the label and set it to visible. On running the application again, you get to see the message 'No Data To Display' as shown in the screenshot below. This is certainly more user friendly than letting the user wonder why the data was not displayed at the first place.

I hope this article was useful and I thank you for viewing it. The History of ASP. Was this article worth reading? Share it with fellow developers too. Feedback - Leave us some adulation, criticism and everything in between! I needed something like that :. I like this coading Thanks for noting down the footer template. Private Sub BindRepeater. Dim dt As New DataTable. Fill dt. Catch ex As Exception. RegisterStartupScript Me , Me. End Try. If rptStudentDetails.

Footer Then. End Class. Now over to you:. Stay tuned and stay connected for more technical updates. Tweet Share Share Share. Lalit Raghuvanshi Read More. We can write our custom message inside the tag and it will be shown when no data will be there.

But in Repeater control we do not have any such tags which supports message displaying when no data is present. There is a way in which you can achieve that, it is described in the following steps:. Name required.



0コメント

  • 1000 / 1000