Hi Elmo,
ButtonField automatically puts the index to CommandArgument property of the
button. Now, because you changed it to TemplateField you are responsible for
binding the value manually yourself:
<asp:GridView runat="server" ID="MyGrid" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" ID="btn"
CommandName="MyCustomCommand"
CommandArgument='<%# Container.DataItemIndex
%>' Text="Click Me" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And the vb.net code behind:
Protected Sub MyGrid_RowCommand(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) _
Handles MyGrid.RowCommand
If e.CommandName = "MyCustomCommand" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = MyGrid.Rows(index)
End If
End Sub
Hope it helps

Signature
Milosz
> I've converted a buttonfield to a TemplateField with a button in it
>
[quoted text clipped - 10 lines]
>
> What am i missing here?
dbelogrlic@gmail.com - 07 Feb 2008 21:02 GMT
On Feb 5, 1:43 am, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
> Hi Elmo,
>
[quoted text clipped - 46 lines]
>
> > What am i missing here?
Thank you,Milos ....You are MASTER