Daily Archives: November 29, 2011
In my previous post I have discussed about how to auto-generate serial no. in a GridView. Extending my previous post, here I am just discussing the same thing for DataList and Repeater controls. I have used DataItemIndex to generate serial no for GridView, which you can find here(http://tiny.cc/f04y7). Now, we can’t use DataItemIndex for DataList or, a Repeater control. For them there is another property called ItemIndex , which will show the anticipated result. ItemIndex is the index number of the DataListItem in the Items collection and index number of the item in the Repeater control in the Items collection. Below is the syntax for ItemIndex-
<ItemTemplate> <%#Container.ItemIndex+1 %> </ItemTemplate>
It is showing anticipated result for me. If anybody has any better idea then please share in the comment.