我有一個GridView
包含Excel工作表記錄。我想將它們添加到我的DataTable
。我想訪問我的GridView的第二行。這是我的一段代碼。如何設置GridView的行
foreach (GridViewRow row in GridView1.Rows)
{
string Template = row.Cells[0].Text;
string Cust_Name = row.Cells[1].Text;
int Invoice_No = int.Parse(row.Cells[2].Text);
}
我想是這樣
int rowNum = GridView1.Rows[1]
,但我得到這個錯誤
無法隱式轉換類型 'System.Web.UI.WebControls.GridViewRow' 到 '廉政'
請參閱[「應該在其標題中包含」標籤?「](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles),其中共識是「不,他們不應該」! –
想要將Excel工作表數據導入到網格視圖,然後查看文章http://codepedia.info/2015/04/import-excel-sheet-data-to-gridview-asp-net-c-sharp/ –
'GridView1.Rows [1]'應該可以工作,那麼你遇到了什麼問題?除此之外,問題還不清楚。您已經通過使用'foreach'循環顯示了訪問GridView中行的不同方式。這種方法有什麼問題? –