private void insertParaGradosTable() { SqlCommand cmd3 = new SqlCommand(); cmd3.Connection = con; cmd3.CommandType = System.Data.CommandType.Text; cmd3.CommandText = "SELECT TOP 1 ID_IND from INDICADORES ORDER BY ID_IND DESC"; SqlDataAdapter da2 = new SqlDataAdapter(cmd3); DataSet ds2 = new DataSet(); DataTable dt2 = new DataTable(); da2.Fill(ds2); dt2 = ds2.Tables[0]; if (cbGradosAsumidos.Checked) { id_gen = int.Parse(dt2.Rows[0][0].ToString()); for (int i = 0; i < gradosInsert.Count; i++) { gradosInsert.ElementAt(i).ID_IND = id_gen; gradosTable = gradosInsert; } } else { id_gen = int.Parse(dt2.Rows[0][0].ToString()); Grados_NoAsumidos gn = new Grados_NoAsumidos(gradosInsert); gn.ShowDialog(); for (int i = 0; i < gradosInsert.Count; i++) { for (int j = 0; j < gn.grados.Count; j++) { if (gradosInsert.ElementAt(i).nombre == gn.grados[j].ToString()) { gradosInsert.ElementAt(i).ID_IND = id_gen; gradosTable.Add(gradosInsert.ElementAt(i)); } } } } }