user10171440
user10171440

Reputation:

How to get the primary key column from a data row?

In my code there is a data row. Is there a way to get the primary key from this or no? My code is:

var PK = data_row.PrimaryKey;

However, this I looked up in the MS docs and there is no PrimaryKey property if a data row, there is a property like that for the data table but I don't have the data table here.

Upvotes: 3

Views: 3422

Answers (1)

G. LC
G. LC

Reputation: 822

You could try the following:

var PK = data_row.Table.PrimaryKey;

this gets the primary key column from the DataTable that the DataRow comes from.

Upvotes: 6

Related Questions