adding multiple items one by one in datagridview in c# window form -


private void btnsave1_click(object sender, eventargs e) {    foreach (datagridviewrow dgvr in productaddgridview.rows)     {         dgvr.cells[0].value = productidtextbox.text;         dgvr.cells[1].value = producttypeidcombobox.text;         dgvr.cells[2].value = companyidcombobox.text;         dgvr.cells[3].value = productpurchaseratetextbox.text;         dgvr.cells[4].value = productqtytextbox.text;         dgvr.cells[5].value = productdescriptionrichtextbox.text;         dgvr.cells[6].value = convert.tostring(convert.touint32(productqtytextbox.text.trim()) * convert.todecimal(productpurchaseratetextbox.text));      } } 

i trying add multiple products 1 one in datagridview before saving database. whenever add row in datagridview second time, first row gets replaced second row -- works single row addition.

i not getting looking if want add multiple row in datagrid view need create data row , can add row in datagrid. can refer link


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -