mallorn mallorn - 3 years ago 362
C# Question

ADGV C# DataGridView - find DataRow to update SQL

I'm trying to use auto-generated advancedDataGrid - ADGV (
My advancedDataGridView1 contains "default" procedures to update-insert-delete SQL Tables.

Update requires DataRow property from the DataGrid, which I'm looking for.
For example: it is filled with data (linked to SQL table) this way:


Question: how to get DataRow property for the selected Row or Column?

int RowIndexNo = advancedDataGridView1.CurrentCell.RowIndex;
int ColIndexNo = advancedDataGridView1.CurrentCell.ColumnIndex;

Answer Source

Try this:

int rowIdx = dataGridView1.CurrentCell.RowIndex;
DataRowView drv = (DataRowView)advancedDataGridView1.Rows[rowIdx].DataBoundItem;
DataRow dr = drv.Row;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download