private void dgvItemSelection_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow selectedRow = dgvItemSelection.SelectedRows[0]; //Store row number of selected row txtItemName.Text = selectedRow.Cells["ItemName"].Value.ToString(); //Set the content of Item Name textbox to the selected row's item name nupItemQuantity.Text = "1"; string partNumber = selectedRow.Cells["PartNo"].Value.ToString(); txtUnitPrice.Text = (sql.SelectItemPrice(partNumber)).ToString(); }