I need to enter the Product details from textbox to gridview row.
If the same Product already in gridview, just update the quantity and rate.
else enter the new row.
the code I have used:
- foreach (DataGridViewRow row1 in dgvmaingrid.Rows)
- {
- if (row1.Cells["PNAME"].Value.Equals(txtProdsearch.Text.Trim()) && row1.Cells["DESC"].Value.Equals(txtDesc.Text.Trim()))
- {
- row1.Cells["QTY1"].Value = (double.Parse(row1.Cells["QTY1"].Value.ToString()) + double.Parse(txtQty.Text));
- row1.Cells["NETAMT"].Value = Convert.ToDecimal(String.Format("{0:0.00}", Convert.ToDecimal((double.Parse(row1.Cells["NETAMT"].Value.ToString()) + double.Parse(txtNetPrice.Text))))).ToString();
- return;
- }
- else if (row1.Cells["PNAME"].Value.ToString() != (txtProdsearch.Text.Trim()) && row1.Cells["DESC"].Value.ToString() != (txtDesc.Text.Trim()))
- {
- dgvmaingrid.Rows.Add();
- snoadd = snoadd + 1;
- row = dgvmaingrid.RowCount - 1;
- dgvmaingrid.Rows[row].Cells["sno"].Value = snoadd;
- dgvmaingrid.Rows[row].Cells["PNAME"].Value = txtProdsearch.Text;
- dgvmaingrid.Rows[row].Cells["DESC"].Value = txtDesc.Text;
- dgvmaingrid.Rows[row].Cells["QTY1"].Value = txtQty.Text;
- dgvmaingrid.Rows[row].Cells["RATE1"].Value = txtUPrice.Text;
- double neti = double.Parse(txtNetPrice.Text);
- dgvmaingrid.Rows[row].Cells["NETAMT"].Value = Convert.ToDecimal(String.Format("{0:0.00}", Convert.ToDecimal(neti))).ToString();
- return;
- }
- }
Thank you in advance...


Rajasekaran BosePosted Jul 30, 2018, 6:17 AM
Nanddeep NachanPosted Jul 12, 2018, 7:05 AM
Rajasekaran BosePosted Jul 12, 2018, 6:37 AM
Rajasekaran BosePosted Jul 9, 2018, 6:58 AM
Nanddeep NachanPosted Jul 9, 2018, 6:45 AM