private void RefreshGrid() { try { Lookup_Vault_CashbookTableAdapter Ta = new Lookup_Vault_CashbookTableAdapter(); Ta.Fill(this.mSCOA_VaultDataSet1.Lookup_Vault_Cashbook); BeginInvoke((MethodInvoker) delegate { BindingSource bs = new BindingSource(); bs.DataSource = this.mSCOA_VaultDataSet1.Lookup_Vault_Cashbook; dataGridView1.DataSource = bs; bs.ResetBindings(false); //dataGridView1.DataSource = this.mSCOA_VaultDataSet1.Lookup_Vault_Cashbook; dataGridView1.Refresh(); }); } catch (Exception ex) { } }
private void btnUpdate_Click(object sender, EventArgs e) { if (cboDirect.SelectedIndex > 0) { foreach (DataGridViewRow row in dataGridView1.Rows) { // do something with the row.. if (row.Selected == true) { //int nID = Convert.ToInt32(row.Cells["Id_Lookup_Vault_Cashbook"].Value); int nID = Convert.ToInt32(row.Cells[row.Cells.Count - 1].Value); string sDirectGUID = cboDirect.SelectedValue.ToString(); Lookup_Vault_CashbookTableAdapter Ta = new Lookup_Vault_CashbookTableAdapter(); Ta.UpdateQueryByID(sDirectGUID, nID); } } LoadData(); } else { MessageBox.Show("Please select a value first in dropdown", "Update Item", MessageBoxButtons.OK); } }