我已經創建了datatable保存在會話&分配給gridview.I必須提取這些記錄,因爲我已經編寫代碼如下,但它的值爲null:如何從gridview中提取行gridview c#
//To find gridview in Formview1
GridView GridView1 = (GridView)Formview1.FindControl("GridView1");
GridView1.DataSource = (DataTable)Session["tabdetails"];
GridView1.DataBind();
string str, str1, str2, str3, str4, str5, str6;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
str = GridView1.Rows[i].Cells[0].Text;
str1 = GridView1.Rows[i].Cells[1].Text;
str3 = GridView1.Rows[i].Cells[2].Text;
str4 = GridView1.Rows[i].Cells[3].Text;
str5 = GridView1.Rows[i].Cells[4].Text;
}
請建議我做正確的更改? 謝謝。 Asp.net c#
如果你不打算編輯UI中的內容,直接從'Session [「tabdetails」];'。這會容易得多。 –
如果要更改UI中的內容,那麼對於每一行,在單元格內找到相應的文本框控件並從中獲取值。 –