GridView template needs to set CommandArgument to row index

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
 
D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top