私のコードは(Asp.Net、C#)です
int index = Convert.ToInt16(e.CommandArgument);
string str = GridView2.DataKeys[index].Value.ToString();
Session["studyuid2"] = str;
2行目は、エラーインデックスが範囲外でした。負ではなく、コレクションのサイズよりも小さい必要があります。パラメータ名:インデックス
そして私のグリッドビューは
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" Height="100px"
RowStyle-Height="25px" HeaderStyle-Height="30px" FooterStyle-Height="30px"
CellPadding=5 CellSpacing=5
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EnableModelValidation="True"
Width="100%"
DataKeyNames="StudyUID"
onrowcommand="GridView2_RowCommand"
AllowSorting="True">
<RowStyle Height="25px"></RowStyle>
<Columns>
-------------------------------
</Columns>
<FooterStyle Height="30px"></FooterStyle>
<HeaderStyle Height="30px"></HeaderStyle>
</asp:GridView>