I have an asp.net page with 5 GridView controls all linked to the same SelectedIndexChanged event as follows
<div id="containerOne" class ="containerLeft">
<h2 class="WorkInProgressHeading">To Analyse</h2>
<asp:LinkedGridView runat="server" ID ="grdAwaitingAnalysis" CssClass="Grid" OnSelectedIndexChanged="grid_SelectedIndexChanged">
<AlternatingRowStyle CssClass="GridAltItem"/>
<RowStyle CssClass="GridItem"/>
<SelectedRowStyle CssClass="GridSelectedItem"/>
</asp:LinkedGridView>
</div>
<div id="containerTwo" class="containerLeft">
<h2 class="WorkInProgressHeading">Analysing...</h2>
<asp:LinkedGridView runat="server" ID="grdAnalysisInProgress" CssClass="Grid" OnSelectedIndexChanged="grid_SelectedIndexChanged">
<AlternatingRowStyle CssClass="GridAltItem"/>
<RowStyle CssClass="GridItem"/>
<SelectedRowStyle CssClass="GridSelectedItem"/>
</asp:LinkedGridView>
</div> etc.....
In the code behind, the event handler is as follows
protected void grid_SelectedIndexChanged(object sender, EventArgs e)
{
var sendingGrid = sender as LinkedGridView;
if (sendingGrid.ID != "grdAwaitingAnalysis") grdAwaitingAnalysis.SelectedIndex = -1;
if (sendingGrid.ID != "grdAnalysisInProgress") grdAnalysisInProgress.SelectedIndex = -1;
if (sendingGrid.ID != "grdAwaitingReporting") grdAwaitingReporting.SelectedIndex = -1;
if (sendingGrid.ID != "grdAwaitingInterp") grdAwaitingInterp.SelectedIndex = -1;
if (sendingGrid.ID != "grdInterpInProgress") grdInterpInProgress.SelectedIndex = -1;
}
I was surprised that this didnt cause a stackoverflow exception because when each selected index is set to -1 i expected the grid_SelectedIndexChanged event to fire again but it didn't.
Is this because it's a web page instead of a WPF / Winforms situation ? I'm relatively new to ASP.NET, so am I wrong in thinking about as similar to a WPF / WinForms app ?
Thanks.