J T

J T

  • NA
  • 16
  • 24.7k

Can't update data in datagridview

Mar 16 2011 4:26 AM
Goal:
Having two buttons that should be enable to add or delete data from datagridview. The changes should be make in real time so you should be see the new result.


Problem:
Having problem to display the new result after I have used button add functionality because the result won't display in real time. In order to view the result I have to close and reopen the application in order to view the new result.

Please remember that I don't use a database.

I'm using class table and then I connect the table to the datagridview's datasource.

// JT



            DataTable table = new DataTable();
            table.Columns.Add("a");
            table.Columns.Add("b");

            foreach (var a in myManagerProduct.GetAllProductList())
            {

                    DataRow row;
                    row = table.NewRow();

                    row["a"] = a._articleNumber;
                    row["b"] = a._name;
                    dgridStock.Rows.Add(row);

                    table.Rows.Add(row);
            }

            dgridStock.DataSource = table;

Answers (12)