If you are just clicking on the row in the GridView
, that will not fire the event. You have to have some kind of button in the row to click on, which will fire the RowCommand
event, as well as the SelectedIndexChanged
event (if the row you click is not already selected, of course). It's not exactly like the Windows Forms DataGridView =)
The easiest way to get the event to fire, is to add this attribute to your GridView
markup:
AutoGenerateSelectButton="True"
This creates a "Select" LinkButton
, which will fire the Gridview1_SelectedIndexChanged2
event in your code-behind when you click it.
EDIT: Just to clarify, this is where you need to add that attribute:
<asp:GridView ID="GridView1" runat="server" GridLines="None"
Width="930px" CellPadding="4" ForeColor="#333333"
onselectedindexchanged="GridView1_SelectedIndexChanged2"
AutoGenerateSelectButton="True" >
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…