views:

254

answers:

3

I face a weird problem. I have a simple aspx page with a dropdownlist. The dropdown gets filled through a function which is called from Page_Load() event. The dropdown item selection triggers event OnSelectedIndexChanged. Now the event triggers rightly but what happens that upon post back the dropdownlist gets initialized, that is, it shows empty. Never faced this type of issue before so i wonder what's happening wrong.

The piece of code follow:

protected void Page_Load(object sender, EventArgs e)
{
     if(!Page.IsPostBack)
        PopulateCompanyList(GetCompanies(serverUNCPath));
    return;
}
+1  A: 

Is ViewState disabled on your dropdownlist, or perhaps the whole application?

Ravish
A: 

The very first ideas:

  1. Check EnableViewState property of your dropdown and all the parent controls up to the root (should not be false)
  2. You perform rebinding on postbacks without storing SelectedValue property
  3. If one of your parent controls is custom or dynamic it may incorrectly persist ViewState info (including children).
UserControl
A: 

Babur were you able to get a solution to this query ever?

Raghu