repeater - show something when no results

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
 
T

Teemu Keiski

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.)
 
J

Jason Bentley

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;
}
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top