2010-11-25 43 views
0

當我嘗試將gridview單元格值傳遞給數組時,一切都很完美,但執行代碼後數組是空的。Gridview的單元格值和數組列表

當我通過調試模式看到所選行的索引也很好,即當我使用1000中的複選框選擇兩行時,count在數組中顯示2,但數據爲空。

我無法從gridview中獲取單元格值。

任何意見將不勝感激。

protected void Button2008_Click(object sender, EventArgs e) 
{ 
    ArrayList checkedItems = new ArrayList(); 

    foreach (GridViewRow row in this.GridView1.Rows) 
    { 
     if (((CheckBox)row.FindControl("cbRows")).Checked == true) 
     { 
     checkedItems.Add(row.Cells[12].Text); 
     } 
    } 

    Session["CheckedItems"] = checkedItems; 

    Response.Redirect("About.aspx", true); 
} 

回答

0

可以使用斷點和檢查哪裏出了問題正在發生,例如,是否row.Cells[12].Text表現出任何價值?

你可以檢查你的aspx頁面在回發之後的行爲。

+0

double。可能12個索引不正確或爲空。記住Cells集合是基於ZERO的。 – jaderanderson 2010-11-25 18:43:54