Wednesday, May 14, 2008
ASP.NET: Sequence Numbers in Data Controls
I came across a requirement to build a bunch of tables with a sequence number as one of the columns of the table. Normally, I would create an ASP.NET table and populate the table through code. However, it can turn in a maintenance nightmare if I ever have to change the code. I looked up the issue on Google, since sequence numbers aren't all that uncommon and found a pretty simple solution. In the item template, all we need to do is bind to "Container.DataItemIndex + 1" and that gives the sequence numbers! That's yet another feature that many developers out there who are starting off with ASP.NET do not know about yet.