On my form I have a DataGridView wich the user can fill manuel with document lines (invoice).
When the user clicks the save doc button the document gets saved to the db and with that new record ID I then Save the documentlines into the db.
Only problem I have is that when there are say 3 rows in the DataGridView it save 3 times the last added row and not row 1,2 and 3.
Below is my code.
So I have a problem somewhere with iterating through the DataGridView but can't find what is wrong..
Thx for any help.
// Add lines to List and fill DocumentBLL.DocRegel
// _localDocBLL is a class wich contains a List with _localRegelBLL items
for (int i = 0; i < dataGridViewDocLijnen.Rows.Count; i++)
// Here i Fill the _localRegelBLL properties with the values of the datagridview
// but something goes wrong here. It adds the last line as many times a there are rows...
_localRegelBLL.Id = Convert.ToInt32(dataGridViewDocLijnen.Rows[i].Cells.Value);
_localRegelBLL.Aantal = Convert.ToDouble(dataGridViewDocLijnen.Rows[i].Cells.Value);
_localRegelBLL.Rgl_oms_id = Convert.ToInt32(dataGridViewDocLijnen.Rows[i].Cells.Value);
_localRegelBLL.Eenheid = dataGridViewDocLijnen.Rows[i].Cells.Value.ToString();
_localRegelBLL.EenheidsPrijs = Convert.ToDouble(dataGridViewDocLijnen.Rows[i].Cells.Value);
_localRegelBLL.TotaalPrijs = Convert.ToDouble(dataGridViewDocLijnen.Rows[i].Cells.Value);
_localRegelBLL.Rgl_doc_id = docId;
// Save document lines
bool saveDocLines = _localDocBLL.SaveDocLines(_localDocBLL.DocRegel);