You are getting this error because you don't have not specified any
CommandArgument
in the Approve
LinkButton
, but trying to access it.
So, if you want to get the index of the
GridView
row from which
LinkButton
is clicked then you need to add that row index in the
CommandArgument
property like below.
<ItemTemplate>
<asp:LinkButton ID="lbnView" runat="server" Text="Approve" CommandName="Approve" CommandArgument="<%#((GridViewRow)Container).RowIndex%>">
</asp:LinkButton>
</ItemTemplate>
As we have given the rowindex to the
CommandArgument
now, so when you execute the code, you will get the index of the row from which the button is clicked.
Refer
Get RowIndex In GridView RowCommand Event Using DataKey[
^] for more details.
Thanks...