. Net repeater displays "no result" when there is no data. Quick Solution

Source: Internet
Author: User

Repeater does not use emptytemplate by default. Try to use the custom control to rewrite databind. I think it is too complicated. I accidentally found an almost invincible method from a foreigner's blog:

Most of us are using repeaters to display data also we faced the situation of retrieving no result to display so the repeater will be empty or we will need to handle this case from code behind to check number of items and if zero we show a label with no result found or no records to display message.

We can do this with a simpler way and with no need to write anything in code behind, let's see how

 

Code
< ASP: repeater ID = " Rptra " Runat = " Server " >

< Itemtemplate >

<! -- Add your item template here -->

</ Itemtemplate >

< Footertemplate >

< ASP: Label ID = " Lblempty "

Text = " No result " Runat = " Server "

Visible = ' <% # Bool. parse (rptra. Items. Count = 0). tostring () %> ' >

</ ASP: Label >

</ Footertemplate >

</ ASP: Repeater >

here we will display a label with "no result" message in the footer we just need to add a label and set it's text property with the message we want.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.