GridView Loosing DataKey

rcombs4

Well-known member
Joined
Aug 6, 2008
Messages
189
Programming Experience
3-5
I'm trying to do something i've done multiple different times, but for some reason something is not working this time.

I have a grid view which I've assigned the DataKeyNames i want.
VB.NET:
<asp:GridView ID="grvPayments" runat="server" AutoGenerateColumns="false" DataKeyNames="MerchantNumber,BatchNumber">
....
</asp:GridView>


But when I try and access the DataKeys property it has a count of 0.

VB.NET:
  Protected Sub grvPayments_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grvPayments.RowCommand
        Response.Write(grvPayments.DataKeys.Count)
        Exit Sub
....
End Sub

Results in 0.


Any help would be appreciated.
 
Back
Top