Is there a reason why the ASP.NET session ending and restarting would interfere with(prevent) the SelectedIndexChanged event firing on a dropdownlist?
The form is posting back but my breakpoint is not being hit?
Everything works perfectly prior to the session restarting.
Here's the asp for the control:
<asp:DropDownList ID="dlSort" runat="server" AutoPostBack="true"
onselectedindexchanged="dlSort_SelectedIndexChanged">
</asp:DropDownList>
Here's a portion of the code:
protected void dlSort_SelectedIndexChanged(object sender, EventArgs e)
{
PopulateItems();
//Breakpoint above- not hit after session restarts, but hit prior to session end.
}
I'm left with an empty form as it's not getting repopulated...
Thanks in advance,
M
Edit 1:
Here is the code where the control is populated:
protected void Page_Load(object sender, EventArgs e)
{
Form.Action = Request.RawUrl;//Required as page is rewritten
if (!IsPostBack)
{
SetNoItemsMessage("");
PopulateSortDropDown();
PopulateItems();
}
}
private void PopulateSortDropDown()
{
clsProducts ops = new clsProducts();
DataTable dt = ops.GetProductSortDropDownData();
dlSortBy.DataSource = dt;
dlSortBy.DataBind();
dlSortBy.ClearSelection();
dlSortBy.SelectedValue = "1";
}
Edit 2:
To clarify, the PopulateItems() method populates a data Repeater and should be run on the index change of the sort drop down(dlSort_SelectedIndexChanged) - this is not happening although the postback is occuring.
Page_Load executes a method that populates dlSort this is always being run.
I have examined the page extensively and everything other than the index change event fires.
Edit 3:
void Session_Start(object sender, EventArgs e)
{
InitialiseCommonSessionVariables();//This piece of code sets default values for session variables that are used in every case.
}
I experienced something similar and had to implement a workaround using the Page_PreRender event to overcome it.
In your case you may be able to test if PopulateItems() has already run and if not run it in pre-render.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With