Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get DataItem when updating GridView

How can I get the underlying DataItem from a GridView row that is in edit mode and the user clicks on "Update"?

I have an editable GridView. I've added a CustomValidator to the Edit view of one of the columns. When the user clicks on Update I run a server validate method and need to get the underlying DataItem of the row being edited so that I can get the primary key of the data item for use in the validation.

GridView1.Rows[GridView1.EditIndex].DataItem;

This does not work. I guess because the GridView isn't databinded on the update command?

like image 738
dtc Avatar asked Oct 27 '25 03:10

dtc


1 Answers

GridView1.DataKeys[GridView1.EditIndex].Value;
like image 71
Kosta Avatar answered Oct 30 '25 14:10

Kosta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!