Sunday, 30 October 2011

To get rowindex in rowcommand event of GridView



Rowindex of a Gridview row, which is a template field(not buttonfield), can be obtained in two ways

  • By writing below code in rowcommand event of GridView
Dim row As GridViewRow = DirectCast(e.CommandSource, LinkButton).NamingContainer
Dim index As Integer = row.RowIndex

  • By adding below code in the designview of the template field
 CommandArgument="<%# Container.DataItemIndex %>"

No comments:

Post a Comment