I currently have a gridview that has an asp:ButtonField as one of the columns. The event handler for the command extracts the row id of the gridview from the command argument and uses that to perform some logic. I now need to switch to using a template field for this column, and want to do something like this:
<asp:TemplateField HeaderText="Action">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:LinkButton CommandName="myaction" CommandArgument="<%#Eval("id")%>" Text="do action" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
My problem is with the CommandArgument attribute - I don't know how to get it to be the row id from the GridView. Eval("id") doesn't work - does anyone know what the name of the row id property is? Or a better way to do this?