I guess there's no single ASP.NET developer who hasn't fought with this problem at least once:

How do I retrieve the row index in a RowCommand event handler when using a Button in a TemplateField of a GridView? Simple, once you know it. Just add

CommandArgument="<%# Container.DataItemIndex %>"

to the button control you are placing in your TemplateField and read the index from the CommandArgument property of the GridViewCommandEventArgs in your event handler.

Curiously enough, the MSDN documentation demonstrates this by using a RowCreated handler, but in my opinion that's way too much code for such a small thing.