facing problem while trying to typecast the value of of gridviewrow.cells value into int32 using C#.net.Please consider the following coding.
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("studentid",typeof(Int32)));
dt.Columns.Add(new DataColumn("Name",typeof(string)));
foreach (GridViewRow row in GridView1.Rows)
{
DataRow dr;
dr = dt.NewRow();
CheckBox cb = (CheckBox)row.FindControl("Chkgridselect");
if ( cb.Checked)
{
//Error occurs in the following line when i try to typecast
dr["studentid"] =Convert.ToInt32( row.Cells[1]);
dr["Name"] = row.Cells[2];
dt.Rows.Add(dr);
}
}
Adding some code would help, but I’m going to take a stab and say to try this: