Saturday, March 24, 2012

Dropdownlist inside a User Control (all inside an updatePanel)

Hi there!

I have a dropdownlist with autopostback=true

The dropdownlist is inside a User control dinamically generated inside an update panel.

When I select a different item from the dropdownlist... "DropDownList1_SelectedIndexChanged" and I try to get the SelectedValue, I always get 0. While debuggin I could discover that the number of Items inside the dropdownlist was 0! (and obbiously the dropdownlist was charged with data)

The incredible thing is that after the first postback, I can select items from the dropdownlist and the SelectedIndexChanged gives me the correct SelectedValue!

Someone can help on this?

Many thanks,

Jbmixed

The problem was that I was doing the dopdownlists databind from a public property (I was getting a list of objects).

Now I am only stablishing the property, and I wait to the Load event to do the databind.

I hope this helps other people.

No comments:

Post a Comment