I have created datatable kept in session & assigned to gridview.I have to extract those records ,for that i have written code as follows but its giving value as null :
//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;
}
Please suggest me to do right changes?
Thank you.
Asp.net c#
Use data keys to store the values that you need to retrieve.
And in your code behind: