2
I have to enter some data into a datagridView
and then need to recover these values and store in a List
or Array
, so that then I can send it to the database.
Guys, I don’t know how to do this! If you gentlemen can help me, I’d be grateful!
Follow an excerpt of the code I’m testing, unsuccessfully..
Note. I can already insert the data with this code below:
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 3;
//Informo os nomes das colunas do dataGridView
dataGridView1.Columns[0].Name = "Nome";
dataGridView1.Columns[1].Name = "E-mail";
dataGridView1.Columns[2].Name = "Telefone";
}
private void Button1_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text);
//limpo os controles
textBox1.Text = String.Empty;
textBox2.Text = String.Empty;
textBox3.Text = String.Empty;
}
private void Button2_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow dataGridViewRow in dataGridView1.Rows)
{
??
}
}
Very good!! I did the tests and it worked!! Thank you Augusto! Augusto, you could explain how I can take these values that are in the individual variables to pass to the bank.. Usually I do it like this: string Resp = ""; Resp = Ncontato.Insert(_name, _email, _phone); ...// but I’m not getting it!
– Phil
@Phil: I don’t know if this is what you asked for but it must be something like :
foreach (Individuo ind in Contatos) { resp = NContato.Inserir(ind.nome, ind.email, ind.telefone); }
– Augusto Vasques
I did as you suggested, but he still does not see the variables name, email and phone... I will continue searching here! Thanks @Augusto
– Phil
Good research, but anything open a specific question about database showing code within
NContato.Inserir
.– Augusto Vasques
Ncontato is a class with the insert method, which in this case is to receive the values of these variables name, email.... Valeu @Augusto!!
– Phil