Jyoti Jodha

Jyoti Jodha

  • NA
  • 1.7k
  • 407k

Update values id don't save in database

Apr 25 2017 2:35 AM
int editrowindex=-1;
//addbutton.Text="Add";
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
var senderGrid = (DataGridView)sender;
if (e.ColumnIndex == dataGridView.Columns["Delete"].Index && e.RowIndex >= 0)
{
dataGridView.Rows.RemoveAt(e.RowIndex);
int i = 1;
foreach (DataGridViewRow g1 in dataGridView.Rows)
{
g1.Cells[0].Value = i;
i++;
}
}
else if (e.ColumnIndex == dataGridView.Columns["Edit"].Index && e.RowIndex >= 0)
{
addbutton.Text = "Update";
editrowindex = e.RowIndex;
comboBoxproduct.Text = "";
comboBoxproduct.SelectedText= dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
dectxt.Text = "";
dectxt.Text = dataGridView.Rows[e.RowIndex].Cells[2].Value.ToString();
txtqty.Text = "";
txtqty.Text= dataGridView.Rows[e.RowIndex].Cells[3].Value.ToString();
combounit.Text = "";
combounit.SelectedText = dataGridView.Rows[e.RowIndex].Cells[4].Value.ToString();
qtytxtprice.Text = "";
qtytxtprice.SelectedText = dataGridView.Rows[e.RowIndex].Cells[5].Value.ToString();
txttax.Text = "";
txttax.SelectedValue = dataGridView.Rows[e.RowIndex].Cells[6].Value.ToString();
Totaltxt.Text = "";
Totaltxt.SelectedText = dataGridView.Rows[e.RowIndex].Cells[7].Value.ToString();
}
}
catch { }
}

Answers (2)