GridView template needs to set CommandArgument to row index

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a template field in a GridView that contains two ImageButtons.
When the user clicks one of the buttons, the GridView's RowCommand
event is fired and I can get the CommandName. All that is fine.
However, e.CommandArgument is an empty string, presumably because the
CommandArgument property of the ImageButtons is not set.

Is there some way, in the markup, to set the CommandArgument to the row
index?

<ItemTemplate>
<asp:ImageButton ID="btnSave" runat="server"
CommandName="Save" ImageUrl="~/Images/Diskette.gif"
CommandArgument="SOMETHING HERE" />&nbsp;&nbsp;
<asp:ImageButton ID="Email" runat="server"
CommandName="Email" ImageUrl="~/Images/Envelope.gif"
CommandArgument="SOMETHING HERE" />
</ItemTemplate>

TIA,

David
 
Thank you for your reply. I had already planned on doing it in the
RowCreated event. I was just hoping there was some way to do it in the
markup.

Thanks again.

David
 
Back
Top