Datagridview

  • Thread starter Thread starter Philipp
  • Start date Start date
P

Philipp

Hi all,

Is there a way to retrieve the rowstate of a row in a datagridview
(added - modified - deleted - ...) ?
Does someone have some info on this or a document/url where I can read
about it?

Thanks in advance!

Philipp
 
You're confusing a DataGridViewRow with the underlying data source. A
DataGridViewRow does not have any such properties. A System.Data.DataRow
does. But you need to confirm to us that your DataGridView is bound to a
table first. If so, the DataGridViewRow has a "DataBoundItem" property which
is of type "object." If it is bound to a DataTable, the DataBoundItem
property will be a DataRowView (most likely). A DataRowView has a "Row"
property which is the underlying DataRow. And *that* has a RowState
property.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.
 
Kevin said:
You're confusing a DataGridViewRow with the underlying data source. A
DataGridViewRow does not have any such properties. A System.Data.DataRow
does. But you need to confirm to us that your DataGridView is bound to a
table first. If so, the DataGridViewRow has a "DataBoundItem" property which
is of type "object." If it is bound to a DataTable, the DataBoundItem
property will be a DataRowView (most likely). A DataRowView has a "Row"
property which is the underlying DataRow. And *that* has a RowState
property.

Thanks!
The DataGridView is indeed bound to a DataTable.
I will try this when I'm back at work in a couple of days.

Thanks for the answer, I'll let you know if it works!

Philipp
 
Kevin Spencer said:
You're confusing a DataGridViewRow with the underlying data source. A
DataGridViewRow does not have any such properties. A System.Data.DataRow
does. But you need to confirm to us that your DataGridView is bound to a
table first. If so, the DataGridViewRow has a "DataBoundItem" property
which is of type "object." If it is bound to a DataTable, the
DataBoundItem property will be a DataRowView (most likely). A DataRowView
has a "Row" property which is the underlying DataRow. And *that* has a
RowState property.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

It is exactly as you describe ... the only problem is that when the
datagridview is bound, the rowstate of all datarows are of type "added".
When something is changed in the DataGridView the state of the underlying
row still is "added".
Am I doing something wrong here ?

Thanks


Greets,
Philipp
 
Back
Top