Repeater vs. ListView
Posted
by MoezMousavi
on Geeks with Blogs
See other posts from Geeks with Blogs
or by MoezMousavi
Published on Thu, 30 Dec 2010 00:25:33 GMT
Indexed on
2010/12/29
14:55 UTC
Read the original article
Hit count: 234
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(" 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
© Geeks with Blogs or respective owner