Q: cascading events not working?

M

Matt C.

I have a dropdown list (ddlReportees) that autopostsback and populates a
listbox (lstEvalHistory). In the event handler for the ddl
SelectedIndexChanged, the top item in lstEvalHistory is selected (see
(1)).

I expected setting lstEvalHistory.SelectedIndex = 0 to fire
SelectedIndexChanged for lstEvalHistory. But it doesn't.

It is no big deal to add a bit of code to get the same effect (2). But
my mental model is off. Can anyone tell me why setting SelectedIndex in
code does not cause SelectedIndexChanged to fire?

Code is below.

Thanks,
Matt



protected void ddlReportees_SelectedIndexChanged(object sender,
EventArgs e)
{
string sEmpl = this.ddlReportees.SelectedValue;
int iEmplID = int.Parse(sEmpl.Substring(2));

this.GetAndDisplayEvaluations(iEmplID);

if (this.lstEvalHistory.Items.Count > 0)
{
this.lstEvalHistory.SelectedIndex = 0; // (1) (why no event?)
this.DisplayEvalText(); // (2) (workaround)
}
else
this.DisplayEmptyEvalTable();

this.ddlReportees.Focus();
}

protected void lstEvalHistory_SelectedIndexChanged(object sender,
EventArgs e)
{
DisplayEvalText();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top