Hello dear, good afternoon. I have a small problem that I no longer know how to solve, I expose
I need to go from one DataGridView to another for this I have the following, I will only show you the image of the form to not be so extensive.
This is the code:
An Aux List
- public class AuxProducto
- {
- public int ProductoId { get; set; }
- public string Codigo { get; set; }
- public string ProductoDescripcion { get; set; }
- public decimal PrecioVenta { get; set; }
- }
A List of the AuxProduct Class
- List<AuxProducto> ListaAuxProducto = new List<AuxProducto>();
The datasource of the datagrid on the right is this
- private void CargarDatagriViewProdPrecioNuevo()
- {
- DataGridViewPrecioNuevo.DataSource = ListaAuxProducto;
- }
The button code that goes from one datagridview to another is this
- private void button1_Click(object sender, EventArgs e)
- {
- foreach (DataGridViewRow fila in DataGridViewPreciosAntiguo.Rows)
- {
- AuxProducto auxProducto = new AuxProducto();
- if (Convert.ToBoolean(fila.Cells["Select"].Value))
- {
- auxProducto.ProductoId = (int)fila.Cells["Id"].Value;
- auxProducto.Codigo = fila.Cells["Codigo"].Value.ToString();
- auxProducto.ProductoDescripcion = fila.Cells["ProductoDescripcion"].Value.ToString();
- auxProducto.PrecioVenta = 0.00M;
- ListaAuxProducto.Add(auxProducto);
- DataGridViewPrecioNuevo.DataSource = null;
- DataGridViewPrecioNuevo.DataSource = ListaAuxProducto;
- }
- }
- }
As you can see, everything does as it should be done, or maybe there is some error please let me know.
In the form on the right, I need to add a new price in the new column, when I click on any part of the datagridview I get the error
where can my mistake be please.
I appreciate the collaboration,
Roberto