On first load ( (!IsPostBack){...} ) MenuOne is populated from a DataSet filled from a SQL database.
I need MenuTwo to be created dynamically when the page processes the MenuOneClick event, so I call Page_Load(object sender, EventArgs e) from the MenuOneClick handler and pass on MenuOne and the MenuOneClick ButtonClickEventArgs to Page_Load() then cast the arguments back to use the information to adapt the SQL query.
Page_Load(object sender, EventArgs e)...
...try
{
BulletedListEventArgs ble = (BulletedListEventArgs)e;
dataSet = new DataSet();
int queryParameter = Convert.ToInt32(MenuOne.Items[ble.Index].Value);
SetupDataSet(queryParameter);
PopulateMenuOne();
}
PopulateMenuOne()
{
...
PopulateMenuTwo();
}
It seems to work for me, but I say that in the same way as would a man who had just driven their car to work in reverse because they'd tried to put their car into first gear and stalled.
I thought initially I should be using a Hidden Field or ViewState but I could only get my MenuTwo to populate with the 'n-minus-oneth' selected option from MenuOne
e.g. if MenuOne was a choice of Animals Cars or SugaryDrinks
when I clicked the first time on Animals, I'd get them the second time I clicked when I selected Cars, then I'd get Cars next when I clicked SugaryDrinks and Sugary Drinks when I then tried Animals again.
I'm staring long and hard at my Page lifecycle diagram now, but I could use some pointers please.
Bookmarks