user3211611
user3211611

Reputation:

How can i retrieve all data and insert into sql from DataGridView

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

Answers (1)

Steve Wellens
Steve Wellens

Reputation: 20640

It looks like you keep overwriting the textbox.

Maybe appending to the textbox is what you need: textBox1.Text += value;

Upvotes: 1

Related Questions