2
int index = -1;
foreach (GridViewRow gvrow in lstHoliday.Rows)
{
    index = (int)lstHoliday.DataKeys[gvrow.RowIndex].Value;
    bool result = ((CheckBox)gvrow.FindControl("Selector")).Checked;
}

ここでエラーを取得します。

index = (int)lstHoliday.DataKeys[gvrow.RowIndex].Value;

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

ここで何が間違っていますか?

ここに画像の説明を入力

4

1 に答える 1

1

マークアップのDataKeyNamesプロパティについてGridView言及する必要があります。エラーの原因は上記ではありませんでした。

DataKeyNamesの詳細

于 2013-03-17T13:47:03.257 に答える