c# - DataGridView SelectedRows returns null -


i don't why selectedrows.tostring() returns null when @ documentation of microsoft.

so here's code :

datagridviewrow row = dgvtransaction.selectedrows[0]; string tempcid = row.cells[0].tostring(); dbop.delete_command(string.format("delete ceramic ceramic_id = '{0}'",tempcid)); 

is there wrong here? datagridview source dataset database though , have changed selection mode full row selection also.

i've been searching question on stack overflow selected rows , none of them answered question. maybe little bit of answer me ^^

edit 1

save changes of datagridview database

that helps me, mate

edited code

datagridviewrow row = dgvtransaction.selectedrows[0]; string tempcid = row.cells[0].value.tostring(); dbop.delete_command(string.format("delete ceramic ceramic_id = '{0}'",tempcid));  dgvtransaction.rows.removeat(row.index); dgvtransaction.refresh(); 

and works. thanks


Comments