Reputation:
i want to retrieve all cell and row from dataGridView and pase in textbox or label,or insert into sql server
i tried to use this
string value;
public void getGridData()
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
value = cell.Value.ToString();
//MessageBox.Show(value);
textBox1.Text = value;
}
}
}
when i user MessaBox.show it works,but in textBoxt nope, please help me
Upvotes: 1
Views: 64
Reputation: 20640
It looks like you keep overwriting the textbox.
Maybe appending to the textbox is what you need: textBox1.Text += value;
Upvotes: 1