Fire SelectionIndexChanged with AutoGenerateSelect "False"
I have a datagrid view, and I'd like to capture a datakeyname value on a
selected row of a gridview. But in this scenario one of my columns (Event
Title) will be a hyperlink, and when this link is clicked it will fire
selectedindexchanged and capture DataKeyName which will be passed to
populate a form. Here's my code. Currently my hyperlink field is not eve
"clickable". Do I need to change my approach?
<asp:GridView ID="gvEventDetails" CssClass="gvEvent" runat="server"
DataKeyNames="Event_ID"
AutoGenerateColumns="false"
OnSelectedIndexChanged="gvEventDetails_SelectedIndexChanged"
>
<Columns>
<asp:TemplateField HeaderText="Event Title">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" Text='<%#
Eval("Event_Title") %>' runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Client Name">
<ItemTemplate>
<asp:Label ID="ClientName" runat="server" Text='<%#
Eval("Name") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
The method:
protected void gvEventDetails_SelectedIndexChanged(object sender,
EventArgs e)
{
string DataKey = gvEventDetails.SelectedValue.ToString();
}
No comments:
Post a Comment