Wednesday, August 24, 2011

Row/Item Count in Repeater



Using below code you can get Repeater's Row/Item Count:

in below code "Container.ItemIndex" is used to get current row number and
"(string[])rpttags.DataSource).Length" is used to get total row/item count.
in above line my datasource for repeater was a string array so i used string[] as datasourcetype and used length to get its count in same way you can get for all other types

eg:-
<%# (Container.ItemIndex < ((yourDataSourceDataType)rpttags.DataSource).Length  - 1?",":"") %>

Compiled By: Rajesh Rolen

Share This!


1 comment:

Anonymous said...

Hi Rajesh.

I realize this is way after your post, but it looks like you're putting a comma between your items.

If that is all, you can just use
<SeparatorTemplate>, </SeparatorTemplate>

Your solution works and has potential benefits for other use cases, but the case you use it for has a simpler solution.

Powered By Blogger · Designed By Seo Blogger Templates