Repeater vs. ListView
- by MoezMousavi
I do really hate repeater. I was more a GridView lover but after 3.5 be born, I prefer ListView. The first problem with Repeater is paging. You will need to write code to handle paging. Second common problem is empty data template. Have a look at this:
if (rptMyRepeater.Items.Count < 1)
{
if (e.Item.ItemType == ListItemType.Footer)
{
Label lblFooter = (Label)e.Item.FindControl("lblEmpty");
lblFooter.Visible = true;
}
}
I found the above code is usefull if you need to show something like "There is no record" is your data source has no records. Although the ListView has a template.
If you combine ListView with a DataPager, you will be in heaven as it is sorting the paging for you without writing code. (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.aspx)
Note: You have got to bind ListView in PreRender, it doesn't work properly in PageLoad
More: http://www.4guysfromrolla.com/articles/061009-1.aspx