Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call dropdownlist selected index changed event manually

i have a dropdown which fill on page load event.

private void FillSponsor()
    {
        ddlSponsor.DataSource = Db.VCT_SPONSORs.Where(x => x.IS_ACTIVE.GetValueOrDefault() && x.IS_APPROVED.GetValueOrDefault());
        ddlSponsor.DataBind();
    }

Now what i want is to bind other dropdown with the first value of above dropdown. my second dropdown is:

protected void ddlSponsor_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddlDivision.DataSource = Db.VCT_SPONSOR_DIVISIONs.Where(x => x.SPONSOR_ID==SponsorID);
        ddlDivision.DataBind();
        ddlDivision.Items.Insert(0, new ListItem("All", "0"));
    }

My problem is how to call ddlSponsor_SelectedIndexChanged event from the FillSponsor method. My both dropdowns are in update panels.

like image 269
Pankaj Avatar asked May 13 '11 05:05

Pankaj


2 Answers

Do you mean how would you call the method?

ddlSponsor_SelectedIndexChanged(this, EventArgs.Empty);
like image 57
TBohnen.jnr Avatar answered Nov 05 '22 23:11

TBohnen.jnr


You can use DateBound Event instead. like...

protected void ddlSponsor_DataBound(object sender, EventArgs e)
{
    ddlDivision.DataSource = Db.VCT_SPONSOR_DIVISIONs.Where(x => x.SPONSOR_ID==SponsorID);
    ddlDivision.DataBind();
    ddlDivision.Items.Insert(0, new ListItem("All", "0"));
}
like image 24
Muhammad Akhtar Avatar answered Nov 05 '22 23:11

Muhammad Akhtar