Copy value from that table adapter to data grid cell, how?
-
What is best method to do this on Order Details data grid, when user select ProductID ProductPrice is automatically filled with value from Product table... and is on save written to Order details (so if price changed in Product table it will not be automatically updated in order details table (only when user select new product)? I already have idea, tried to do new table adapter that have parameter query that do just that, and have event celled edit call fill on new table adapter... only remaining problem is how to copy new value to existing tableadapter. I tried some work around things... but none is very professional so I'm looking for some elegant solution. So how to copy value from that table adapter to data grid cell if possible (I only managed to drag and drop new table adapter and create text box on form, so I copy value of text box to grid, not something I would like to do)?
-
What is best method to do this on Order Details data grid, when user select ProductID ProductPrice is automatically filled with value from Product table... and is on save written to Order details (so if price changed in Product table it will not be automatically updated in order details table (only when user select new product)? I already have idea, tried to do new table adapter that have parameter query that do just that, and have event celled edit call fill on new table adapter... only remaining problem is how to copy new value to existing tableadapter. I tried some work around things... but none is very professional so I'm looking for some elegant solution. So how to copy value from that table adapter to data grid cell if possible (I only managed to drag and drop new table adapter and create text box on form, so I copy value of text box to grid, not something I would like to do)?
OK this can give you some idea...
private void order_DetailsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (order_DetailsDataGridView.Columns[e.ColumnIndex].DataPropertyName == "ProductID") {this.getProductCurrentPriceTableAdapter.Fill (this.northWndDataSet.GetProductCurrentPrice, (int)order_DetailsDataGridView[e.ColumnIndex, e.RowIndex].Value); order_DetailsDataGridView[e.ColumnIndex + 1, e.RowIndex].Value = decimal.Parse(unitPriceTextBox.Text); } }
so instead last line I want something better, any idea? -
OK this can give you some idea...
private void order_DetailsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (order_DetailsDataGridView.Columns[e.ColumnIndex].DataPropertyName == "ProductID") {this.getProductCurrentPriceTableAdapter.Fill (this.northWndDataSet.GetProductCurrentPrice, (int)order_DetailsDataGridView[e.ColumnIndex, e.RowIndex].Value); order_DetailsDataGridView[e.ColumnIndex + 1, e.RowIndex].Value = decimal.Parse(unitPriceTextBox.Text); } }
so instead last line I want something better, any idea?No one? Anyone please?