If you just click on a row in a GridView
, this will not raise an event. You should have some button in the row for a click that will trigger the RowCommand
event, as well as the SelectedIndexChanged
event (if the row you selected is not already selected, of course). This is not quite the same as Windows Forms DataGridView =)
The easiest way to fire an event is to add this attribute to your GridView
markup:
AutoGenerateSelectButton="True"
This creates a โSelectโ LinkButton
that will fire the Gridview1_SelectedIndexChanged2
event in your code when you click it.
EDIT: To clarify, you need to add this attribute:
<asp:GridView ID="GridView1" runat="server" GridLines="None" Width="930px" CellPadding="4" ForeColor="#333333" onselectedindexchanged="GridView1_SelectedIndexChanged2" AutoGenerateSelectButton="True" >
source share