datakey

Get DataKey values in GridView RowCommand

I have a GridView with an associated DataKey, which is the item ID. How do I retrieve that value inside the RowCommand event? This seems to work, but I don't like the cast to LinkButton (what if some other command is firing the event?), and I'm not too confident about the NamingContainer bit. LinkButton lb = (LinkButton)e.CommandSource...

GridView Paging, unable to get the correct Datakey value

GridView <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" PagerSettings-Position="TopAndBottom" PagerSettings-Mode="Numeric" PageSize="40" CellPadding="4" DataSourceID="dsEquipmentGridView" ForeColor="#333333" GridLines="Horizontal" Style="font-size: x-small" AutoGenerateColumns="False" ...