+1  A: 

I guess this is too late... But first, you are trying to get data keys right after data retrieval and not after data bind. DataKeys do not get populated until DataBind.

Second, data keys do not store new post-update values. They are copies of what was available during binding, stored in the view state, and used primarily to locate records after a post back w/o doing another bind.

Ruslan
A: 

I had this problem with a GridView that was in a asp:PlaceHolder that was set to Visible=false when the page loaded. The data binding happened for the entire page in OnLoad for !IsPostBack. When a button was clicked the PlaceHolder would be set to Visible=true. All of the data would show up but the DataKeys[] on the GridView would always be empty.

It seems like the GridView ViewState does not persist correctly when the control is not visible. My remedy is to DataBind() the GridView right before I display it.

jkg0