我使用此代碼來獲取在GridView控件last row
的索引,然後把空字符串在特定的細胞,但拋出錯誤:Index out of range
爲什麼索引超出範圍異常?
protected void grdViewAdvances_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int RowIndex = grdViewAdvances.Rows.Count-1 ;
grdViewAdvances.Rows[RowIndex].Cells[5].Text = "";
}
您在GridView中有多少列? – Adil
@Adil Guess> = 5。 – tchelidze
嘗試給3或4在單元格來檢查是否由於列或行 – Adil