I have this gridview:
<div class="content">
<asp:GridView ID="DocumentGrid" runat="server" AutoGenerateColumns="False" OnRowCommand="DocumentGrid_RowCommand" >
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID" ItemStyle-Width="120px"/>
<asp:ButtonField HeaderText="Download Link" Text="Download"/>
</Columns>
</asp:GridView>
</div>
As you can see, DocumentGrid_RowCommand is called when the “Download” button is pressed, How can I find out what the values are of the row that was clicked?
If more than one button fields are there in GridView, set
CommandNameattribute. That way we can determine which button is pressed in RowCommand event. So always set commandName attribute.In
RowCommandevent handler,GridViewCommandEventArgs.CommandArgumentproperty returns index of row on which button is pressed.