Get DataItem When Updating GridView

How can I get the base DataItem from the GridView row in edit mode and the user clicks the Refresh button?

I have an editable GridView. I added a CustomValidator to the Edit view of one of the columns. When the user clicks Refresh, I run the server validation method and should get the underlying DataItem of the editable string so that I can get the primary key of the data item for use in validation.

GridView1.Rows[GridView1.EditIndex].DataItem;

This does not work. I think because the GridView is not tied to the data in the update command?

+3
source share
2 answers
GridView1.DataKeys[GridView1.EditIndex].Value;
+7
source

All Articles