Hi,
I am current trying to add data from a GridView to a DataTable, as mentioned below
DataTable dt = new DataTable("GridView_Data"); foreach (TableCell cell in gvMain.HeaderRow.Cells) { dt.Columns.Add(cell.Text); } foreach (GridViewRow row in gvMain.Rows) { dt.Rows.Add(); for (int i = 0; i < row.Cells.Count; i++) { dt.Rows[dt.Rows.Count - 1][i] = row.Cells[i].Text; } }
The row.Cells[i].Text always comes blank as the cell contains asp.net controls, Label and TextBox. Is it possible to check what type of control is present in that cell and get its value.
There are close to 40 cells/colums in the GridView and each has either a Label or TextBox. I don’t want use FindControl("String id") for every cell.
Thanks
Regards, Vikram