private void button1_Click(object sender, EventArgs e) { string txt; int i = dataGridView1.CurrentCell.RowIndex; int id = Convert.ToInt32(dataGridView1[0, i].Value); string FIO = Convert.ToString(dataGridView1[1, i].Value); string position = Convert.ToString(dataGridView1[2, i].Value); switch (dataGridView1.CurrentCell.ColumnIndex) { case 1: txt = Interaction.InputBox("Enter new data:"); us.UpdateUser(id, FIO, position, id, txt, position); break; case 2: txt = Interaction.InputBox("Enter new data:"); us.UpdateUser(id, FIO, position, id, FIO, txt); break; } this.Refreshi(); }