AFofandi
AFofandi

Reputation: 41

can I call dropdownlist selectedIndexchanged before PageLoad event?

When changing the value in dropdownlist. selectedIndexchange should call before PageLoad event.

How can I call dropdownlist selectedIndexchanged before PageLoad event?

Upvotes: 2

Views: 10974

Answers (1)

Sudhakar Tillapudi
Sudhakar Tillapudi

Reputation: 26209

as per ASP.NET Life cycle Page_Load Event Fires first and then the other control events will be fired.

but you can fire the dropDownList SelectedIndexChanged event by calling SelectedIndexChanged event manually from Page_Load event handling code as a first step.

Try This:

protected void Page_Load(object sender, EventArgs e)
{
        //call the DropDownList1 selectedindexchanged event manually
        dropDownList1_SelectedIndexChanged(sender, e);

       //page load event handling code

}

protected void dropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
     //DropDownList1 SelectedIndexChanged event handling code.
}

Upvotes: 2

Related Questions