ciao a tutti, avrei un problema: ho una gridview con 5 colonne e 11 righe.
Devo convertirla in un datatable; prima di tutto aggiungo le colonne:
foreach (DataControlField colum in this.mygrid.Columns)
{
mydatatable.Columns.Add(colum.HeaderText);
}
e poi aggiungo le righe al datatatable, basandomi sulla gridview:
foreach (GridViewRow row in this.mygrid.Rows)
{
mydatatable.Rows.Add
(
row.Cells[row.RowIndex].Text,
((TextBox)(this.mygrid.Rows[row.RowIndex].FindControl("mycontrol"))).Text,
((CheckBox)(this.mygrid.Rows[row.RowIndex].FindControl("mycontro2"))).Checked,
((CheckBox)(this.mygrid.Rows[row.RowIndex].FindControl("mycontro3"))).Checked,
((CheckBox)(this.mygrid.Rows[row.RowIndex].FindControl("mycontro4"))).Checked
);
}
il problema è che funziona fino all'indice 5,
andando poi in errore su row.Cells[row.RowIndex].Text
e non capisco perchè..di diverso c'è che è di tipo boundfield questo campo.
grazie