簡體   English   中英

使用gridview asp.net進行分頁時索引超出范圍

[英]Index out of range when paging using gridview asp.net

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

我在這里做錯了什么?

在此處輸入圖片說明

需要提及標記上GridViewDataKeyNames屬性。 上面沒有提到導致錯誤的原因。

有關DataKeyNames的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM