repeater - show something when no results

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys

How do I get a repeater to show a "sorry, no results found" message (within
the repeater) when I'm using DataBind?

Cheers


Dan
 
You would need to check that from dataSource (or Repeater itself,
Items.Count being greater than 0), and render it out yourself somewhere say
into a Label. Repeater itself holds no template for this (but such is coming
into ASP.NET v2 though it is at least for GridView, can't remember now if
other controls have similar feature.)
 
if(datasource.Rows.Count == 0)
{
Repeater.Visible = false;
Label1.Visible = true;
Label1.Text = "Sorry, no results found.";
}
else
{
Repeater.Databind();
Repeater.Visible = true;
Label1.Visible = false;
}
 
Thanks guys... thats great cheers.

I'm gutted that it won't let me put it in the Repeater though - roll on BETA
2!!

Cheers


Dan
 
Back
Top