Using a couple sites as guides I'm able to access a GridView_SelectedIndexChanged event and get the SelectedDataKey.Value.
Here is how:
Add a Gridview Control to a Admin Role in the LoginView. Add your own named event to the OnSelectedIndexChange event.
<asp:RoleGroup Roles="Admin">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="PCC_ID" DataSourceID="dsPCC"
OnSelectedIndexChanged="MyGVW_SelectedIndexChanged">
<Columns>
....
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="dsPCC" runat="server" ConnectionString=
"<%$ ConnectionStrings:PCC_SQL_Connection %
>"SelectCommand="SELECT [PCC_ID], [Product], [Brand_Name],
[Cat_Name], [GBU_DisplayName], [PCC_Author], [PCC_name]
FROM [vw_PCC]">
</asp:SqlDataSource>
</ContentTemplate>
</asp:RoleGroup>
CodeBehind:
Protected Sub MyGVW_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim MyGVW As GridView = CType(Me.LoginView1.FindControl("GridView1"), GridView)
Dim MyRow As GridViewRow = CType(Me.LoginView1.FindControl("GridView1"), GridView).SelectedRow
Dim intPC_ID As Integer
intPC_ID = MyGVW.SelectedDataKey.Value
BinaryRender(intPC_ID)
End Sub
Using the above example I'm able to get the 'Key' Value from the Gridview, which is embeded in a LoginView Control.
Here are the sites I used as examples:
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/login/loginview.aspx
http://forums.asp.net/thread/1666668.aspx
Hope this helps,
rwiethorn
rwiethorn<no-Spam>@gmail.com